Mercurial > dive4elements > river
annotate flys-backend/src/main/java/de/intevation/flys/model/CrossSection.java @ 2875:444e52222941
Added lower and upper km to functions that return bed height singles and epochs for a given river.
flys-backend/trunk@4442 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 18 May 2012 12:31:26 +0000 |
parents | e237a08acf6e |
children | 2ae732e2c65c |
rev | line source |
---|---|
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.model; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import java.io.Serializable; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import java.util.List; |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
6 import java.util.ArrayList; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
7 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
8 import java.awt.geom.Point2D; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 import javax.persistence.Entity; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import javax.persistence.Id; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import javax.persistence.Table; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 import javax.persistence.GeneratedValue; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 import javax.persistence.Column; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 import javax.persistence.SequenceGenerator; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import javax.persistence.GenerationType; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import javax.persistence.OneToOne; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 import javax.persistence.OneToMany; |
1210
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1204
diff
changeset
|
19 import javax.persistence.OrderBy; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 import javax.persistence.JoinColumn; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 |
2379
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
22 import java.math.MathContext; |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
23 import java.math.BigDecimal; |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
24 |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
25 import org.hibernate.Session; |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
26 import org.hibernate.SQLQuery; |
2379
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
27 import org.hibernate.Query; |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
28 |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
29 import org.hibernate.type.StandardBasicTypes; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
30 |
2379
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
31 import de.intevation.flys.backend.SessionHolder; |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
32 |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 @Entity |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 @Table(name = "cross_sections") |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 public class CrossSection |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 implements Serializable |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 { |
2379
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
38 public static final MathContext PRECISION = new MathContext(6); |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
39 |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
40 public static final String SQL_FAST_CROSS_SECTION_LINES = |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
41 "SELECT km, x, y, csl.id AS csl_id " + |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
42 "FROM cross_section_lines csl JOIN cross_section_points csp " + |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
43 "ON csp.cross_section_line_id = csl.id " + |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
44 "WHERE csl.cross_section_id = :cs_id AND " + |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
45 "km between :from_km AND :to_km " + |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
46 "ORDER BY csl.id, csp.col_pos"; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
47 |
1203
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
48 private Integer id; |
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
49 private River river; |
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
50 private TimeInterval timeInterval; |
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
51 private String description; |
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
52 private List<CrossSectionLine> lines; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 public CrossSection() { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 |
1204
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
57 public CrossSection( |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
58 River river, |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
59 TimeInterval timeInterval, |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
60 String description |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
61 ) { |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
62 this.river = river; |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
63 this.timeInterval = timeInterval; |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
64 this.description = description; |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
65 } |
22858e7cca79
Integrated PRF parsing into importer. Needs testing!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1203
diff
changeset
|
66 |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 @Id |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 @SequenceGenerator( |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 name = "SEQUENCE_CROSS_SECTIONS_ID_SEQ", |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 sequenceName = "CROSS_SECTIONS_ID_SEQ", |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 allocationSize = 1) |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 @GeneratedValue( |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 strategy = GenerationType.SEQUENCE, |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 generator = "SEQUENCE_CROSS_SECTIONS_ID_SEQ") |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 @Column(name = "id") |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 public Integer getId() { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 return id; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 public void setId(Integer id) { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 this.id = id; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 @OneToOne |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 @JoinColumn(name = "river_id") |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 public River getRiver() { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 return river; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 public void setRiver(River river) { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 this.river = river; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 @OneToOne |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 @JoinColumn(name = "time_interval_id") |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 public TimeInterval getTimeInterval() { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 return timeInterval; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 public void setTimeInterval(TimeInterval timeInterval) { |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 this.timeInterval = timeInterval; |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 |
1202
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
104 @Column(name = "description") |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
105 public String getDescription() { |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
106 return description; |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
107 } |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
108 |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
109 public void setDescription(String description) { |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
110 this.description = description; |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
111 } |
44581b40b968
Schema: Added description column to the cross section table
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1194
diff
changeset
|
112 |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 @OneToMany |
1210
31d8638760b1
New. The hibernate models
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1204
diff
changeset
|
114 @OrderBy("km") |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 @JoinColumn(name="cross_section_id") |
1203
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
116 public List<CrossSectionLine> getLines() { |
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
117 return lines; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 |
1203
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
120 public void setLines(List<CrossSectionLine> lines) { |
3c01bef43a98
Querprofile: Added a table to map the points to a given km.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1202
diff
changeset
|
121 this.lines = lines; |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 } |
2379
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
123 |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
124 public List<CrossSectionLine> getLines(double startKm, double endKm) { |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
125 Session session = SessionHolder.HOLDER.get(); |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
126 Query query = session.createQuery( |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
127 "from CrossSectionLine where crossSection=:crossSection " + |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
128 "and km between :startKm and :endKm order by km"); |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
129 query.setParameter("crossSection", this); |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
130 query.setParameter("startKm", new BigDecimal(startKm, PRECISION)); |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
131 query.setParameter("endKm", new BigDecimal(endKm, PRECISION)); |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
132 |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
133 return query.list(); |
8be27b950dbe
CrossSection: Added method to extract the lines of a given km range.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1210
diff
changeset
|
134 } |
2380
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
135 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
136 public List<FastCrossSectionLine> getFastLines( |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
137 double startKm, |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
138 double endKm |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
139 ) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
140 Session session = SessionHolder.HOLDER.get(); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
141 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
142 SQLQuery sqlQuery = session.createSQLQuery(SQL_FAST_CROSS_SECTION_LINES) |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
143 .addScalar("km", StandardBasicTypes.DOUBLE) |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
144 .addScalar("x", StandardBasicTypes.DOUBLE) |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
145 .addScalar("y", StandardBasicTypes.DOUBLE) |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
146 .addScalar("csl_id", StandardBasicTypes.INTEGER); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
147 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
148 sqlQuery |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
149 .setInteger("cs_id", getId()) |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
150 .setDouble("from_km", startKm) |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
151 .setDouble("to_km", endKm); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
152 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
153 List<Object []> results = sqlQuery.list(); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
154 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
155 ArrayList<Point2D> points = new ArrayList<Point2D>(500); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
156 ArrayList<FastCrossSectionLine> lines = |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
157 new ArrayList<FastCrossSectionLine>(); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
158 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
159 Integer lastId = null; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
160 Double lastKm = null; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
161 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
162 for (Object [] result: results) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
163 Double km = (Double)result[0]; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
164 Double x = (Double)result[1]; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
165 Double y = (Double)result[2]; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
166 Integer id = (Integer)result[3]; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
167 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
168 if (lastId != null && !lastId.equals(id)) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
169 points.trimToSize(); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
170 FastCrossSectionLine line = |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
171 new FastCrossSectionLine(lastKm, points); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
172 lines.add(line); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
173 points = new ArrayList<Point2D>(500); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
174 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
175 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
176 Point2D p = new Point2D.Double(x, y); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
177 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
178 if (CrossSectionLine.isValid(p)) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
179 points.add(p); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
180 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
181 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
182 lastKm = km; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
183 lastId = id; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
184 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
185 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
186 if (lastId != null) { |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
187 points.trimToSize(); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
188 FastCrossSectionLine line = |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
189 new FastCrossSectionLine(lastKm, points); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
190 lines.add(line); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
191 } |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
192 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
193 lines.trimToSize(); |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
194 |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
195 return lines; |
e237a08acf6e
Create fast cross section lines in the backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2379
diff
changeset
|
196 } |
1194
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
197 } |
491892931761
Added Hibernate models for cross-sections and their points.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
198 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |