Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java @ 8199:42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 05 Sep 2014 12:22:42 +0200 |
parents | 8d447516b7dd |
children | 4b8c5a08de04 |
comparison
equal
deleted
inserted
replaced
8198:fdec8ab16fa7 | 8199:42ac86ec19c7 |
---|---|
15 import java.util.Date; | 15 import java.util.Date; |
16 import java.util.List; | 16 import java.util.List; |
17 import java.util.TreeMap; | 17 import java.util.TreeMap; |
18 import java.util.TreeSet; | 18 import java.util.TreeSet; |
19 | 19 |
20 import org.dive4elements.river.backend.utils.EpsilonComparator; | 20 import org.apache.log4j.Logger; |
21 | |
22 import org.dive4elements.river.utils.EpsilonComparator; | |
21 | 23 |
22 public class SedimentLoadData implements Serializable | 24 public class SedimentLoadData implements Serializable |
23 { | 25 { |
26 private static Logger logger = Logger.getLogger(SedimentLoadData.class); | |
27 | |
24 public static final int GF_UNKNOWN = -1; | 28 public static final int GF_UNKNOWN = -1; |
25 public static final int GF_COARSE = 0; | 29 public static final int GF_COARSE = 0; |
26 public static final int GF_FINE_MIDDLE = 1; | 30 public static final int GF_FINE_MIDDLE = 1; |
27 public static final int GF_SAND = 2; | 31 public static final int GF_SAND = 2; |
28 public static final int GF_SUSP_SAND = 3; | 32 public static final int GF_SUSP_SAND = 3; |
102 | 106 |
103 public static class Load implements Serializable { | 107 public static class Load implements Serializable { |
104 | 108 |
105 private int id; | 109 private int id; |
106 private int kind; | 110 private int kind; |
111 private int sqRelId; | |
107 | 112 |
108 private String description; | 113 private String description; |
109 | 114 |
110 private Date startTime; | 115 private Date startTime; |
111 private Date stopTime; | 116 private Date stopTime; |
117 private Date sqStartTime; | |
118 private Date sqStopTime; | |
112 | 119 |
113 public Load() { | 120 public Load() { |
114 } | 121 } |
115 | 122 |
116 public Load( | 123 public Load( |
117 int id, | 124 int id, |
118 int kind, | 125 int kind, |
119 String description, | 126 String description, |
120 Date startTime, | 127 Date startTime, |
121 Date stopTime | 128 Date stopTime, |
129 int sqRelId, | |
130 Date sqStartTime, | |
131 Date sqStopTime | |
122 ) { | 132 ) { |
123 this.id = id; | 133 this.id = id; |
124 this.kind = kind; | 134 this.kind = kind; |
125 this.description = description; | 135 this.description = description; |
126 this.startTime = startTime; | 136 this.startTime = startTime; |
127 this.stopTime = stopTime; | 137 this.stopTime = stopTime; |
138 this.sqStartTime = sqStartTime; | |
139 this.sqStopTime = sqStopTime; | |
140 this.sqRelId = sqRelId; | |
141 logger.debug("Creating Load with sqrelid: " + sqRelId + " start: "+ sqStartTime); | |
128 } | 142 } |
129 | 143 |
130 public int getId() { | 144 public int getId() { |
131 return id; | 145 return id; |
132 } | 146 } |
133 | 147 |
148 public int getSQRelationTimeIntervalId() { | |
149 return sqRelId; | |
150 } | |
151 | |
134 public int getKind() { | 152 public int getKind() { |
135 return kind; | 153 return kind; |
136 } | 154 } |
137 | 155 |
138 public String getDescription() { | 156 public String getDescription() { |
142 public Date getStartTime() { | 160 public Date getStartTime() { |
143 return startTime; | 161 return startTime; |
144 } | 162 } |
145 | 163 |
146 public Date getStopTime() { | 164 public Date getStopTime() { |
165 return stopTime; | |
166 } | |
167 | |
168 public Date getSQStartTime() { | |
169 return startTime; | |
170 } | |
171 | |
172 public Date getSQStopTime() { | |
147 return stopTime; | 173 return stopTime; |
148 } | 174 } |
149 | 175 |
150 public boolean isEpoch() { | 176 public boolean isEpoch() { |
151 return startTime != null && stopTime != null; | 177 return startTime != null && stopTime != null; |
412 public int compare(Load a, Load b) { | 438 public int compare(Load a, Load b) { |
413 return a.getId() - b.getId(); | 439 return a.getId() - b.getId(); |
414 } | 440 } |
415 }; | 441 }; |
416 | 442 |
443 public static final Comparator<Load> LOAD_SQ_TI_CMP = new Comparator<Load>() { | |
444 @Override | |
445 public int compare(Load a, Load b) { | |
446 return a.getSQRelationTimeIntervalId() - b.getSQRelationTimeIntervalId(); | |
447 } | |
448 }; | |
449 | |
450 public static final Comparator<Load> LOAD_ID_SQ_TI_CMP = new Comparator<Load>() { | |
451 @Override | |
452 public int compare(Load a, Load b) { | |
453 return LOAD_ID_CMP.compare(a, b) + LOAD_SQ_TI_CMP.compare(a,b); | |
454 } | |
455 }; | |
456 | |
457 /** Find all loads in the range a/b with the according sq_time_interval */ | |
458 public Collection<Load> findLoads(double a, double b, int sqRelationTimeInterval) { | |
459 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_SQ_TI_CMP); | |
460 | |
461 findStations(a, b, new Visitor() { | |
462 @Override | |
463 public void visit(Station station) { | |
464 station.allLoads(loads); | |
465 } | |
466 }); | |
467 | |
468 return loads; | |
469 } | |
470 | |
471 /** Get a list of loads with unique sq_time_intervals. | |
472 * | |
473 * This is mainly a convenience function for the SedimentLoadInfoService. | |
474 */ | |
475 public Collection<Load> findUniqueTimeIntervalLoads(double a, double b) { | |
476 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_SQ_TI_CMP); | |
477 | |
478 findStations(a, b, new Visitor() { | |
479 @Override | |
480 public void visit(Station station) { | |
481 station.allLoads(loads); | |
482 } | |
483 }); | |
484 | |
485 return loads; | |
486 } | |
487 | |
417 public Collection<Load> findLoads(double a, double b) { | 488 public Collection<Load> findLoads(double a, double b) { |
418 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP); | 489 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP); |
419 | 490 |
420 findStations(a, b, new Visitor() { | 491 findStations(a, b, new Visitor() { |
421 @Override | 492 @Override |