Mercurial > dive4elements > river
annotate flys-backend/src/main/java/de/intevation/flys/model/River.java @ 4901:1071aacd042c
Added view to datacage db to get location/distance information.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 29 Jan 2013 17:06:50 +0100 |
parents | 8062b571884d |
children |
rev | line source |
---|---|
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.model; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
4809
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
3 import de.intevation.flys.backend.SessionHolder; |
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
4 |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import java.io.Serializable; |
465
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
6 import java.math.BigDecimal; |
768 | 7 import java.math.MathContext; |
4809
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
8 import java.util.Comparator; |
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
9 import java.util.List; |
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
10 import java.util.Map; |
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
11 import java.util.TreeMap; |
465
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
12 |
4809
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
13 import javax.persistence.Column; |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
14 import javax.persistence.Entity; |
4809
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
15 import javax.persistence.GeneratedValue; |
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
16 import javax.persistence.GenerationType; |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
17 import javax.persistence.Id; |
4809
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
18 import javax.persistence.JoinColumn; |
174
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
19 import javax.persistence.OneToMany; |
2347
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
20 import javax.persistence.OneToOne; |
4262
87c3a3ac6ddf
Order MeasurementStations by station km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4245
diff
changeset
|
21 import javax.persistence.OrderBy; |
4809
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
22 import javax.persistence.SequenceGenerator; |
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
23 import javax.persistence.Table; |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
24 |
4809
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
25 import org.hibernate.Query; |
472
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
26 import org.hibernate.Session; |
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
27 |
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
28 |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
29 @Entity |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
30 @Table(name = "rivers") |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 public class River |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 implements Serializable |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 { |
768 | 34 public static final MathContext PRECISION = new MathContext(6); |
35 | |
2383
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
36 public static final double EPSILON = 1e-5; |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
37 |
4809
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
38 public static final Comparator<Double> KM_CMP = new Comparator<Double>() { |
2383
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
39 @Override |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
40 public int compare(Double a, Double b) { |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
41 double diff = a - b; |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
42 if (diff < -EPSILON) return -1; |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
43 if (diff > EPSILON) return +1; |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
44 return 0; |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
45 } |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
46 }; |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
47 |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
48 private Integer id; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 |
3946
948c7289fc42
Backend: Added 'official_number' column to rivers table to model the 'Bundeswasserstrassen Identnummer'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3945
diff
changeset
|
50 private Long officialNumber; |
948c7289fc42
Backend: Added 'official_number' column to rivers table to model the 'Bundeswasserstrassen Identnummer'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3945
diff
changeset
|
51 |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
52 private String name; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 |
505
ce9c6f05f464
Schema: Added a column which tells if a river counts its km up or downwards.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
488
diff
changeset
|
54 private boolean kmUp; |
ce9c6f05f464
Schema: Added a column which tells if a river counts its km up or downwards.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
488
diff
changeset
|
55 |
174
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
56 private List<Gauge> gauges; |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
57 |
4245
6302db90b63f
Add MeasurementStation to the River
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3947
diff
changeset
|
58 private List<MeasurementStation> measurementstations; |
6302db90b63f
Add MeasurementStation to the River
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3947
diff
changeset
|
59 |
2347
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
60 private Unit wstUnit; |
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
61 |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
62 @Id |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
63 @SequenceGenerator( |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
169
diff
changeset
|
64 name = "SEQUENCE_RIVERS_ID_SEQ", |
169
7929f4144d2f
Bound Apache Commons DBCP with Hibernate.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
65 sequenceName = "RIVERS_ID_SEQ", |
7929f4144d2f
Bound Apache Commons DBCP with Hibernate.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
66 allocationSize = 1) |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
67 @GeneratedValue( |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
68 strategy = GenerationType.SEQUENCE, |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
169
diff
changeset
|
69 generator = "SEQUENCE_RIVERS_ID_SEQ") |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
70 @Column(name = "id") |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
71 public Integer getId() { |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
72 return id; |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
73 } |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
74 |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
75 public void setId(Integer id) { |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 this.id = id; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 |
3946
948c7289fc42
Backend: Added 'official_number' column to rivers table to model the 'Bundeswasserstrassen Identnummer'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3945
diff
changeset
|
79 @Column(name = "official_number") |
948c7289fc42
Backend: Added 'official_number' column to rivers table to model the 'Bundeswasserstrassen Identnummer'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3945
diff
changeset
|
80 public Long getOfficialNumber() { |
948c7289fc42
Backend: Added 'official_number' column to rivers table to model the 'Bundeswasserstrassen Identnummer'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3945
diff
changeset
|
81 return officialNumber; |
948c7289fc42
Backend: Added 'official_number' column to rivers table to model the 'Bundeswasserstrassen Identnummer'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3945
diff
changeset
|
82 } |
948c7289fc42
Backend: Added 'official_number' column to rivers table to model the 'Bundeswasserstrassen Identnummer'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3945
diff
changeset
|
83 |
948c7289fc42
Backend: Added 'official_number' column to rivers table to model the 'Bundeswasserstrassen Identnummer'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3945
diff
changeset
|
84 public void setOfficialNumber(Long officialNumber) { |
948c7289fc42
Backend: Added 'official_number' column to rivers table to model the 'Bundeswasserstrassen Identnummer'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3945
diff
changeset
|
85 this.officialNumber = officialNumber; |
948c7289fc42
Backend: Added 'official_number' column to rivers table to model the 'Bundeswasserstrassen Identnummer'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3945
diff
changeset
|
86 } |
948c7289fc42
Backend: Added 'official_number' column to rivers table to model the 'Bundeswasserstrassen Identnummer'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3945
diff
changeset
|
87 |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
88 @Column(name = "name") |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
89 public String getName() { |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
90 return name; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 public void setName(String name) { |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 this.name = name; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 |
505
ce9c6f05f464
Schema: Added a column which tells if a river counts its km up or downwards.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
488
diff
changeset
|
97 @Column(name = "km_up") |
ce9c6f05f464
Schema: Added a column which tells if a river counts its km up or downwards.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
488
diff
changeset
|
98 public boolean getKmUp() { |
ce9c6f05f464
Schema: Added a column which tells if a river counts its km up or downwards.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
488
diff
changeset
|
99 return kmUp; |
ce9c6f05f464
Schema: Added a column which tells if a river counts its km up or downwards.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
488
diff
changeset
|
100 } |
ce9c6f05f464
Schema: Added a column which tells if a river counts its km up or downwards.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
488
diff
changeset
|
101 |
ce9c6f05f464
Schema: Added a column which tells if a river counts its km up or downwards.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
488
diff
changeset
|
102 public void setKmUp(boolean kmUp) { |
ce9c6f05f464
Schema: Added a column which tells if a river counts its km up or downwards.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
488
diff
changeset
|
103 this.kmUp = kmUp; |
ce9c6f05f464
Schema: Added a column which tells if a river counts its km up or downwards.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
488
diff
changeset
|
104 } |
ce9c6f05f464
Schema: Added a column which tells if a river counts its km up or downwards.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
488
diff
changeset
|
105 |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 public River() { |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 } |
169
7929f4144d2f
Bound Apache Commons DBCP with Hibernate.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
108 |
2347
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
109 public River(String name, Unit wstUnit) { |
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
110 this.name = name; |
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
111 this.wstUnit = wstUnit; |
169
7929f4144d2f
Bound Apache Commons DBCP with Hibernate.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
112 } |
174
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
113 |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
114 @OneToMany |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
115 @JoinColumn(name="river_id") |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
116 public List<Gauge> getGauges() { |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
117 return gauges; |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
118 } |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
119 |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
120 public void setGauges(List<Gauge> gauges) { |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
121 this.gauges = gauges; |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
122 } |
188
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
123 |
2347
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
124 |
4245
6302db90b63f
Add MeasurementStation to the River
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3947
diff
changeset
|
125 @OneToMany |
4262
87c3a3ac6ddf
Order MeasurementStations by station km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
4245
diff
changeset
|
126 @OrderBy("station") |
4245
6302db90b63f
Add MeasurementStation to the River
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3947
diff
changeset
|
127 @JoinColumn(name="river_id") |
6302db90b63f
Add MeasurementStation to the River
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3947
diff
changeset
|
128 public List<MeasurementStation> getMeasurementStations() { |
6302db90b63f
Add MeasurementStation to the River
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3947
diff
changeset
|
129 return measurementstations; |
6302db90b63f
Add MeasurementStation to the River
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3947
diff
changeset
|
130 } |
6302db90b63f
Add MeasurementStation to the River
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3947
diff
changeset
|
131 |
6302db90b63f
Add MeasurementStation to the River
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3947
diff
changeset
|
132 public void setMeasurementStations(List<MeasurementStation> mstations) { |
6302db90b63f
Add MeasurementStation to the River
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3947
diff
changeset
|
133 this.measurementstations = mstations; |
6302db90b63f
Add MeasurementStation to the River
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3947
diff
changeset
|
134 } |
6302db90b63f
Add MeasurementStation to the River
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3947
diff
changeset
|
135 |
2347
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
136 @OneToOne |
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
137 @JoinColumn(name = "wst_unit_id" ) |
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
138 public Unit getWstUnit() { |
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
139 return wstUnit; |
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
140 } |
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
141 |
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
142 public void setWstUnit(Unit wstUnit) { |
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
143 this.wstUnit = wstUnit; |
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
144 } |
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
145 |
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
146 |
0acf28a3d28a
Removed the Unit from Wsts - added a WstUnit column to rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2345
diff
changeset
|
147 |
4809
8062b571884d
Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
Christian Lins <christian.lins@intevation.de>
parents:
4262
diff
changeset
|
148 @Override |
188
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
149 public String toString() { |
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
150 return name != null ? name : ""; |
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
151 } |
465
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
152 |
472
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
153 |
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
154 /** |
488
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
155 * This method returns the gauges that intersect with <i>a</i> and |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
156 * <i>b</i>, |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
157 * |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
158 * @param a A start point. |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
159 * @param b An end point. |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
160 * |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
161 * @return the intersecting gauges. |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
162 */ |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
163 public List<Gauge> determineGauges(double a, double b) { |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
164 Session session = SessionHolder.HOLDER.get(); |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
165 |
756
ca13926b8871
River: Make search for gauges independent of from/to order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
505
diff
changeset
|
166 if (a > b) { double t = a; a = b; b = t; } |
ca13926b8871
River: Make search for gauges independent of from/to order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
505
diff
changeset
|
167 |
488
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
168 Query query = session.createQuery( |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
169 "from Gauge where river=:river " + |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
170 "and not (range.a > :b or range.b < :a) order by a"); |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
171 query.setParameter("river", this); |
769
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
172 query.setParameter("a", new BigDecimal(a, PRECISION)); |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
173 query.setParameter("b", new BigDecimal(b, PRECISION)); |
488
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
174 |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
175 return query.list(); |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
176 } |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
177 |
769
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
178 public Gauge maxOverlap(double a, double b) { |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
179 List<Gauge> gauges = determineGauges(a, b); |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
180 if (gauges == null) { |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
181 return null; |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
182 } |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
183 |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
184 if (a > b) { double t = a; a = b; b = t; } |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
185 |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
186 double max = -Double.MAX_VALUE; |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
187 |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
188 Gauge result = null; |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
189 |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
190 for (Gauge gauge: gauges) { |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
191 Range r = gauge.getRange(); |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
192 double c = r.getA().doubleValue(); |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
193 double d = r.getB().doubleValue(); |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
194 |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
195 double start = c >= a ? c : a; |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
196 double stop = d <= b ? d : b; |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
197 |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
198 double length = stop - start; |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
199 |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
200 if (length > max) { |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
201 max = length; |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
202 result = gauge; |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
203 } |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
204 } |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
205 |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
206 return result; |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
207 } |
321b9e480f72
Added a method to river to find the gauge with the max overlap with a given interval.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
208 |
767
5572d051347e
River: Added method to find gauge by its name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
764
diff
changeset
|
209 public Gauge determineGaugeByName(String name) { |
5572d051347e
River: Added method to find gauge by its name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
764
diff
changeset
|
210 Session session = SessionHolder.HOLDER.get(); |
5572d051347e
River: Added method to find gauge by its name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
764
diff
changeset
|
211 Query query = session.createQuery( |
5572d051347e
River: Added method to find gauge by its name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
764
diff
changeset
|
212 "from Gauge where river=:river and name=:name"); |
5572d051347e
River: Added method to find gauge by its name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
764
diff
changeset
|
213 query.setParameter("river", this); |
5572d051347e
River: Added method to find gauge by its name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
764
diff
changeset
|
214 query.setParameter("name", name); |
5572d051347e
River: Added method to find gauge by its name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
764
diff
changeset
|
215 List<Gauge> gauges = query.list(); |
5572d051347e
River: Added method to find gauge by its name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
764
diff
changeset
|
216 return gauges.isEmpty() ? null : gauges.get(0); |
5572d051347e
River: Added method to find gauge by its name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
764
diff
changeset
|
217 } |
5572d051347e
River: Added method to find gauge by its name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
764
diff
changeset
|
218 |
764
e09f00ecb915
river model: Added method to find gauge by a position lying in its range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
757
diff
changeset
|
219 public Gauge determineGaugeByPosition(double p) { |
e09f00ecb915
river model: Added method to find gauge by a position lying in its range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
757
diff
changeset
|
220 Session session = SessionHolder.HOLDER.get(); |
e09f00ecb915
river model: Added method to find gauge by a position lying in its range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
757
diff
changeset
|
221 Query query = session.createQuery( |
768 | 222 "from Gauge g where river=:river " + |
223 "and :p between g.range.a and g.range.b"); | |
764
e09f00ecb915
river model: Added method to find gauge by a position lying in its range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
757
diff
changeset
|
224 query.setParameter("river", this); |
768 | 225 query.setParameter("p", new BigDecimal(p, PRECISION)); |
764
e09f00ecb915
river model: Added method to find gauge by a position lying in its range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
757
diff
changeset
|
226 List<Gauge> gauges = query.list(); |
e09f00ecb915
river model: Added method to find gauge by a position lying in its range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
757
diff
changeset
|
227 return gauges.isEmpty() ? null : gauges.get(0); |
e09f00ecb915
river model: Added method to find gauge by a position lying in its range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
757
diff
changeset
|
228 } |
e09f00ecb915
river model: Added method to find gauge by a position lying in its range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
757
diff
changeset
|
229 |
757
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
230 public Gauge determineGaugeByStation(double a, double b) { |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
231 |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
232 if (a > b) { double t = a; a = b; b = t; } |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
233 |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
234 Session session = SessionHolder.HOLDER.get(); |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
235 |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
236 Query query = session.createQuery( |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
237 "from Gauge where river.id=:river " + |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
238 "and station between :a and :b"); |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
239 query.setParameter("river", getId()); |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
240 query.setParameter("a", new BigDecimal(a)); |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
241 query.setParameter("b", new BigDecimal(b)); |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
242 |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
243 List<Gauge> gauges = query.list(); |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
244 return gauges.isEmpty() ? null : gauges.get(0); |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
245 } |
c19d4c643526
River: add method to find gauge by its station position.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
756
diff
changeset
|
246 |
3794
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
247 public double[] determineMinMaxQ() { |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
248 Session session = SessionHolder.HOLDER.get(); |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
249 |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
250 Query query = session.createQuery( |
3795
f210432f4383
Fix hibernate query
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3794
diff
changeset
|
251 "select min(wqr.q) as min, max(wqr.q) as max " + |
f210432f4383
Fix hibernate query
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3794
diff
changeset
|
252 "from Wst as w " + |
f210432f4383
Fix hibernate query
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3794
diff
changeset
|
253 "join w.columns as wc " + |
f210432f4383
Fix hibernate query
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3794
diff
changeset
|
254 "join wc.columnQRanges as wcqr " + |
f210432f4383
Fix hibernate query
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3794
diff
changeset
|
255 "join wcqr.wstQRange as wqr " + |
f210432f4383
Fix hibernate query
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3794
diff
changeset
|
256 "where w.kind = 0 and river_id = :river"); |
3794
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
257 |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
258 query.setParameter("river", getId()); |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
259 |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
260 double minmax[] = new double[] { Double.MAX_VALUE, Double.MIN_VALUE }; |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
261 |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
262 List<Object> results = query.list(); |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
263 |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
264 if (!results.isEmpty()) { |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
265 Object[] arr = (Object[]) results.get(0); |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
266 BigDecimal minq = (BigDecimal)arr[0]; |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
267 BigDecimal maxq = (BigDecimal)arr[1]; |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
268 minmax[0] = minq.doubleValue(); |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
269 minmax[1] = maxq.doubleValue(); |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
270 } |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
271 |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
272 return minmax; |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
273 } |
42db09d101f3
Add new method determineMinMaxQ to the River class to fetch the mimimum and maximum q values
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
2384
diff
changeset
|
274 |
488
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
275 |
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
276 /** |
472
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
277 * This method returns the first gauge that is intersected by <i>a</i> and |
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
278 * <i>b</i>, |
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
279 * |
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
280 * @param a A start point. |
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
281 * @param b An end point. |
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
282 * |
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
283 * @return the first intersecting gauge. |
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
284 */ |
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
285 public Gauge determineGauge(double a, double b) { |
488
b316d2106598
River got a new method that returns all gauges intersected by a given start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
472
diff
changeset
|
286 List<Gauge> gauges = determineGauges(a, b); |
472
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
287 |
2345
c3ea91aee989
Bugfix: #333 Improved determination of reference gauge based on start km.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
769
diff
changeset
|
288 int idx = a < b ? 0 : gauges.size() - 1; |
c3ea91aee989
Bugfix: #333 Improved determination of reference gauge based on start km.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
769
diff
changeset
|
289 |
c3ea91aee989
Bugfix: #333 Improved determination of reference gauge based on start km.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
769
diff
changeset
|
290 return gauges.isEmpty() ? null : gauges.get(idx); |
472
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
291 } |
1e196c75563b
Added a new method to determine the selected gauge of a river based on a start and end point.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
465
diff
changeset
|
292 |
465
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
293 /** |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
294 * Returns the min and max distance of this river. The first position in the |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
295 * resulting array contains the min distance, the second position the max |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
296 * distance. |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
297 * |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
298 * @return the min and max distance of this river. |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
299 */ |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
300 public double[] determineMinMaxDistance() { |
2373
056b3a5aa181
Removed "NOT NULL" constraint from gauges.range_id because there are gauges which dont have a Gueltigkeitsbereich.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2347
diff
changeset
|
301 List<Gauge> gauges = getGauges(); |
056b3a5aa181
Removed "NOT NULL" constraint from gauges.range_id because there are gauges which dont have a Gueltigkeitsbereich.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2347
diff
changeset
|
302 |
056b3a5aa181
Removed "NOT NULL" constraint from gauges.range_id because there are gauges which dont have a Gueltigkeitsbereich.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2347
diff
changeset
|
303 if (gauges == null || gauges.isEmpty()) { |
465
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
304 return null; |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
305 } |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
306 |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
307 double minmax[] = new double[] { Double.MAX_VALUE, Double.MIN_VALUE }; |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
308 |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
309 for (Gauge g: gauges) { |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
310 Range r = g.getRange(); |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
311 |
2373
056b3a5aa181
Removed "NOT NULL" constraint from gauges.range_id because there are gauges which dont have a Gueltigkeitsbereich.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2347
diff
changeset
|
312 if (r == null) { |
056b3a5aa181
Removed "NOT NULL" constraint from gauges.range_id because there are gauges which dont have a Gueltigkeitsbereich.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2347
diff
changeset
|
313 continue; |
056b3a5aa181
Removed "NOT NULL" constraint from gauges.range_id because there are gauges which dont have a Gueltigkeitsbereich.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2347
diff
changeset
|
314 } |
056b3a5aa181
Removed "NOT NULL" constraint from gauges.range_id because there are gauges which dont have a Gueltigkeitsbereich.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2347
diff
changeset
|
315 |
465
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
316 double a = r.getA().doubleValue(); |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
317 minmax[0] = minmax[0] < a ? minmax[0] : a; |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
318 |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
319 BigDecimal bigB = r.getB(); |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
320 if (bigB != null) { |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
321 double b = bigB.doubleValue(); |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
322 minmax[1] = minmax[1] > b ? minmax[1] : b; |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
323 } |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
324 } |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
325 |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
326 return minmax; |
c2c3ad4fda58
Added a method to River that returns the min and max distance of the river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
188
diff
changeset
|
327 } |
2383
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
328 |
2384
385170ff7b34
River: (fix) Renamed function which is not a getter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2383
diff
changeset
|
329 public Map<Double, Double> queryGaugeDatumsKMs() { |
2383
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
330 List<Gauge> gauges = getGauges(); |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
331 Map result = new TreeMap<Double, Double>(KM_CMP); |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
332 |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
333 for (Gauge gauge: gauges) { |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
334 BigDecimal km = gauge.getStation(); |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
335 BigDecimal datum = gauge.getDatum(); |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
336 if (km != null && datum != null) { |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
337 result.put(km.doubleValue(), datum.doubleValue()); |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
338 } |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
339 } |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
340 |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
341 return result; |
6605dcd6745f
Added a method to build a map from gauge stations to the datums of the gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2373
diff
changeset
|
342 } |
3944
5fea100c5334
Add a new method to River and Gauge classes to return a http url for additional
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3795
diff
changeset
|
343 |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
344 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
345 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |