Mercurial > dive4elements > river
annotate flys-backend/src/main/java/de/intevation/flys/model/CrossSectionTrack.java @ 4179:30e4de04c658
Moved flys-client/Changes to flys-client/CHANGES.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 18 Oct 2012 20:12:23 +0200 |
parents | d42249d91f47 |
children | 88e3473a3846 |
rev | line source |
---|---|
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.model; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.io.Serializable; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.math.BigDecimal; |
1235
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
5 import java.util.List; |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import javax.persistence.Column; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import javax.persistence.Entity; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import javax.persistence.Id; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import javax.persistence.JoinColumn; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import javax.persistence.OneToOne; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import javax.persistence.Table; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
1235
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
14 import org.hibernate.Query; |
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
15 import org.hibernate.Session; |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import org.hibernate.annotations.Type; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import com.vividsolutions.jts.geom.LineString; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
1235
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
20 import de.intevation.flys.backend.SessionHolder; |
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
21 |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 @Entity |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 @Table(name = "cross_section_tracks") |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 public class CrossSectionTrack |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 implements Serializable |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 { |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 private Integer id; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 private River river; |
3330
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
30 private String name; |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 private LineString geom; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 private BigDecimal km; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 private BigDecimal z; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 public CrossSectionTrack() { |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 } |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 @Id |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 @Column(name = "id") |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 public Integer getId() { |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 return id; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 } |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 public void setId(Integer id) { |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 this.id = id; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 } |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 @OneToOne |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 @JoinColumn(name = "river_id") |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 public River getRiver() { |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 return river; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 } |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 public void setRiver(River river) { |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 this.river = river; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 } |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
3330
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
63 @Column(name = "name") |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
64 public String getName() { |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
65 return name; |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
66 } |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
67 |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
68 |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
69 public void setName(String name) { |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
70 this.name = name; |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
71 } |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
72 |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
73 |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 @Column(name = "geom") |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 @Type(type = "org.hibernatespatial.GeometryUserType") |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 public LineString getGeom() { |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 return geom; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 } |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 public void setGeom(LineString geom) { |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 this.geom = geom; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 } |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 @Column(name = "km") |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 public BigDecimal getKm() { |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 return km; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 } |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 public void setKm(BigDecimal km) { |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 this.km = km; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 } |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 @Column(name = "z") |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 public BigDecimal getZ() { |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 return z; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 } |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 public void setZ(BigDecimal z) { |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 this.z = z; |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 } |
1235
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
106 |
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
107 |
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
108 public static List<CrossSectionTrack> getCrossSectionTrack( |
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
109 String river) |
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
110 { |
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
111 Session session = SessionHolder.HOLDER.get(); |
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
112 |
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
113 Query query = session.createQuery( |
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
114 "from CrossSectionTrack where river.name =:river"); |
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
115 query.setParameter("river", river); |
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
116 |
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
117 return query.list(); |
47ce1fab8464
Added a static function that returns all CrossSectionTracks of a specific river.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1230
diff
changeset
|
118 } |
2341
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
119 |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
120 |
3330
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
121 public static List<CrossSectionTrack> getCrossSectionTrack( |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
122 String river, |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
123 String name |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
124 ) { |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
125 Session session = SessionHolder.HOLDER.get(); |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
126 |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
127 Query query = session.createQuery( |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
128 "from CrossSectionTrack as cst " + |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
129 " where river.name =:river" + |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
130 " and cst.name=:name"); |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
131 query.setParameter("river", river); |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
132 query.setParameter("name", name); |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
133 |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
134 return query.list(); |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
135 } |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
136 |
d42249d91f47
Added missing 'name' property and a new function to retrieve CrossSectionTracks.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2341
diff
changeset
|
137 |
2341
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
138 /** |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
139 * Returns the nearest CrossSectionTrack of <i>river</i> to a given |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
140 * <i>km</i>. |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
141 * |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
142 * @param river The name of a river. |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
143 * @param km The kilometer value. |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
144 * |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
145 * @return the nearest CrossSectionTrack to <i>km</i> of river <i>river</i>. |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
146 */ |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
147 public static CrossSectionTrack getCrossSectionTrack( |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
148 String river, |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
149 double km |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
150 ) { |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
151 Session session = SessionHolder.HOLDER.get(); |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
152 |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
153 Query query = session.createQuery( |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
154 "from CrossSectionTrack where river.name =:river " + |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
155 "order by abs( km - :mykm)"); |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
156 query.setParameter("river", river); |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
157 query.setParameter("mykm", new BigDecimal(km)); |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
158 |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
159 List<CrossSectionTrack> cst = query.list(); |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
160 |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
161 return cst != null && !cst.isEmpty() ? cst.get(0) : null; |
8e2fe935ddf1
Added function to retrieve nearest CrossSectionTrack to a given kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1235
diff
changeset
|
162 } |
1230
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 } |
e2deda3b77a7
Introduced support for FLYS spatial data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |