Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java Fri Sep 05 12:19:13 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java Fri Sep 05 12:22:42 2014 +0200 @@ -17,10 +17,14 @@ import java.util.TreeMap; import java.util.TreeSet; -import org.dive4elements.river.backend.utils.EpsilonComparator; +import org.apache.log4j.Logger; + +import org.dive4elements.river.utils.EpsilonComparator; public class SedimentLoadData implements Serializable { + private static Logger logger = Logger.getLogger(SedimentLoadData.class); + public static final int GF_UNKNOWN = -1; public static final int GF_COARSE = 0; public static final int GF_FINE_MIDDLE = 1; @@ -104,11 +108,14 @@ private int id; private int kind; + private int sqRelId; private String description; private Date startTime; private Date stopTime; + private Date sqStartTime; + private Date sqStopTime; public Load() { } @@ -118,19 +125,30 @@ int kind, String description, Date startTime, - Date stopTime + Date stopTime, + int sqRelId, + Date sqStartTime, + Date sqStopTime ) { this.id = id; this.kind = kind; this.description = description; this.startTime = startTime; this.stopTime = stopTime; + this.sqStartTime = sqStartTime; + this.sqStopTime = sqStopTime; + this.sqRelId = sqRelId; + logger.debug("Creating Load with sqrelid: " + sqRelId + " start: "+ sqStartTime); } public int getId() { return id; } + public int getSQRelationTimeIntervalId() { + return sqRelId; + } + public int getKind() { return kind; } @@ -147,6 +165,14 @@ return stopTime; } + public Date getSQStartTime() { + return startTime; + } + + public Date getSQStopTime() { + return stopTime; + } + public boolean isEpoch() { return startTime != null && stopTime != null; } @@ -414,6 +440,51 @@ } }; + public static final Comparator<Load> LOAD_SQ_TI_CMP = new Comparator<Load>() { + @Override + public int compare(Load a, Load b) { + return a.getSQRelationTimeIntervalId() - b.getSQRelationTimeIntervalId(); + } + }; + + public static final Comparator<Load> LOAD_ID_SQ_TI_CMP = new Comparator<Load>() { + @Override + public int compare(Load a, Load b) { + return LOAD_ID_CMP.compare(a, b) + LOAD_SQ_TI_CMP.compare(a,b); + } + }; + + /** Find all loads in the range a/b with the according sq_time_interval */ + public Collection<Load> findLoads(double a, double b, int sqRelationTimeInterval) { + final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_SQ_TI_CMP); + + findStations(a, b, new Visitor() { + @Override + public void visit(Station station) { + station.allLoads(loads); + } + }); + + return loads; + } + + /** Get a list of loads with unique sq_time_intervals. + * + * This is mainly a convenience function for the SedimentLoadInfoService. + */ + public Collection<Load> findUniqueTimeIntervalLoads(double a, double b) { + final TreeSet<Load> loads = new TreeSet<Load>(LOAD_SQ_TI_CMP); + + findStations(a, b, new Visitor() { + @Override + public void visit(Station station) { + station.allLoads(loads); + } + }); + + return loads; + } + public Collection<Load> findLoads(double a, double b) { final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP);