Mercurial > dive4elements > river
annotate flys-backend/src/main/java/de/intevation/flys/model/Range.java @ 5818:a4ff4167be1e
Request feature info on all layers and show it as html if
the server does not return valid gml.
Non queryable layers produce an error message when the request
fails. This is good enough
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 24 Apr 2013 17:33:27 +0200 |
parents | 80b9218ac007 |
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 |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import java.io.Serializable; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import java.math.BigDecimal; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
7 import javax.persistence.Entity; |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
8 import javax.persistence.Id; |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
9 import javax.persistence.Table; |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
10 import javax.persistence.GeneratedValue; |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
11 import javax.persistence.Column; |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
12 import javax.persistence.SequenceGenerator; |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
13 import javax.persistence.GenerationType; |
174
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
172
diff
changeset
|
14 import javax.persistence.JoinColumn; |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
172
diff
changeset
|
15 import javax.persistence.OneToOne; |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
16 |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
17 @Entity |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
18 @Table(name = "ranges") |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 public class Range |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 implements Serializable |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 { |
5743
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
22 public static final double EPSILON = 1e-5; |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
23 private Integer id; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 private BigDecimal a; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 private BigDecimal b; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 private River river; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 public Range() { |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 |
204
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
32 public Range(double a, double b, River river) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
33 this(new BigDecimal(a), new BigDecimal(b), river); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
34 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
35 |
201
3169b559ca3c
Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
189
diff
changeset
|
36 public Range(BigDecimal a, BigDecimal b, River river) { |
3169b559ca3c
Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
189
diff
changeset
|
37 this.a = a; |
3169b559ca3c
Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
189
diff
changeset
|
38 this.b = b; |
3169b559ca3c
Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
189
diff
changeset
|
39 this.river = river; |
3169b559ca3c
Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
189
diff
changeset
|
40 } |
3169b559ca3c
Build models for wsts, wst columns and q ranges and store them in the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
189
diff
changeset
|
41 |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
42 @Id |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
43 @SequenceGenerator( |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
44 name = "SEQUENCE_RANGES_ID_SEQ", |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
45 sequenceName = "RANGES_ID_SEQ", |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
46 allocationSize = 1) |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
47 @GeneratedValue( |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
48 strategy = GenerationType.SEQUENCE, |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
49 generator = "SEQUENCE_RANGES_ID_SEQ") |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
50 @Column(name = "id") |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
51 public Integer getId() { |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
52 return id; |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
53 } |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
54 |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
167
diff
changeset
|
55 public void setId(Integer id) { |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 this.id = id; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
172
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
59 @Column(name = "a") // FIXME: type mapping needed? |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
60 public BigDecimal getA() { |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
61 return a; |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
62 } |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
63 |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 public void setA(BigDecimal a) { |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 this.a = a; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 |
172
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
68 @Column(name = "b") // FIXME: type mapping needed? |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
69 public BigDecimal getB() { |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
70 return b; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 public void setB(BigDecimal b) { |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 this.b = b; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 |
5743
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
77 public boolean containsTolerant(double x) { |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
78 return containsTolerant(x, EPSILON); |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
79 } |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
80 |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
81 public boolean containsTolerant(double x, double tolerance) { |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
82 BigDecimal b = this.b != null ? this.b : a; |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
83 double av = a.doubleValue(); |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
84 double bv = b.doubleValue(); |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
85 if (av > bv) { |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
86 double t = av; |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
87 av = bv; |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
88 bv = t; |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
89 } |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
90 return x+tolerance >= av && x-tolerance <= bv; |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
91 } |
80b9218ac007
Add containsTolerant to Range.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5587
diff
changeset
|
92 |
5587
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
93 public boolean contains(double x) { |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
94 BigDecimal b = this.b != null ? this.b : a; |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
95 double av = a.doubleValue(); |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
96 double bv = b.doubleValue(); |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
97 if (av > bv) { |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
98 double t = av; |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
99 av = bv; |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
100 bv = t; |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
101 } |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
102 return x >= av && x <= bv; |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
103 } |
7b1c5fe4ebf3
Simplified inner loop of water level exporter.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
205
diff
changeset
|
104 |
188
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
105 @OneToOne |
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
106 @JoinColumn(name = "river_id") |
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
107 public River getRiver() { |
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
108 return river; |
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
109 } |
003ac16812dd
Store annotations in backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
110 |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 public void setRiver(River river) { |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 this.river = river; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 } |
204
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
114 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
115 public int code() { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
116 int code = 0; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
117 if (a != null) code = 1; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
118 if (b != null) code |= 2; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
119 return code; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
120 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
121 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
122 public boolean intersects(BigDecimal c) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
123 return !(a.compareTo(c) > 0 || b.compareTo(c) < 0); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
124 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
125 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
126 public boolean intersects(Range other) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
127 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
128 int code = code(); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
129 int ocode = other.code(); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
130 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
131 if (code == 0 || ocode == 0) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
132 return false; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
133 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
134 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
135 switch (code) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
136 case 1: // has a |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
137 switch (ocode) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
138 case 1: // has a |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
139 return a.compareTo(other.a) == 0; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
140 case 2: // has b |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
141 return a.compareTo(other.b) == 0; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
142 case 3: // has range |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
143 return other.intersects(a); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
144 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
145 break; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
146 case 2: // has b |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
147 switch (ocode) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
148 case 1: // has a |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
149 return b.compareTo(other.a) == 0; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
150 case 2: // has b |
205
697d1faa8217
Forgot to save the last change before commit.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
204
diff
changeset
|
151 return b.compareTo(other.b) == 0; |
204
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
152 case 3: // has range |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
153 return other.intersects(b); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
154 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
155 break; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
156 case 3: // has range |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
157 switch (ocode) { |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
158 case 1: // has a |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
159 return intersects(other.a); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
160 case 2: // has b |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
161 return intersects(other.b); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
162 case 3: // has range |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
163 return !(other.b.compareTo(a) < 0 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
164 ||other.a.compareTo(b) > 0); |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
165 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
166 break; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
167 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
168 } |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
169 |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
170 return false; |
764835268e2b
Added methods to find out if two ranges intersects.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
201
diff
changeset
|
171 } |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
172 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
173 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |