# HG changeset patch # User Sascha L. Teichmann # Date 1404920037 -7200 # Node ID 963ede7b32bb1a91d8df6b016ba28e6e4a9bede4 # Parent f7f86f4e4c8d3e11e7630a6342c167faddb48b11 Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend. diff -r f7f86f4e4c8d -r 963ede7b32bb artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java Wed Jul 09 17:10:18 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java Wed Jul 09 17:33:57 2014 +0200 @@ -27,7 +27,7 @@ import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; import org.dive4elements.river.artifacts.model.Calculation; import org.dive4elements.river.artifacts.model.CalculationResult; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoad; +import org.dive4elements.river.artifacts.model.minfo.SedimentLoadLSData; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFacet; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFactory; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadResult; @@ -87,7 +87,7 @@ String river = getDataAsString("river"); // TODO use cache if possible - SedimentLoad myLoad = SedimentLoadFactory.getSedimentLoadWithDataUncached(id, river); + SedimentLoadLSData myLoad = SedimentLoadFactory.getSedimentLoadWithDataUncached(id, river); return new CalculationResult( new SedimentLoadResult[] { new SedimentLoadResult(1983,2042,myLoad) diff -r f7f86f4e4c8d -r 963ede7b32bb artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoad.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoad.java Wed Jul 09 17:10:18 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,264 +0,0 @@ -/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde - * Software engineering by Intevation GmbH - * - * This file is Free Software under the GNU AGPL (>=v3) - * and comes with ABSOLUTELY NO WARRANTY! Check out the - * documentation coming with Dive4Elements River for details. - */ - -package org.dive4elements.river.artifacts.model.minfo; - -import java.util.Date; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -import org.dive4elements.river.artifacts.model.NamedObjectImpl; -import org.dive4elements.river.artifacts.model.Range; -import org.dive4elements.river.utils.EpsilonComparator; - -import org.apache.log4j.Logger; - - -/** Gives access to Fractions (at kms). */ -public class SedimentLoad -extends NamedObjectImpl -{ - /** Private logger. */ - private static final Logger logger = Logger - .getLogger(SedimentLoad.class); - - protected String description; - protected Date start; - protected Date end; - protected boolean isEpoch; - protected String unit; - - protected Map kms; - - public SedimentLoad() { - kms = new TreeMap(EpsilonComparator.CMP); - } - - public SedimentLoad( - String description, - Date start, - Date end, - boolean isEpoch, - String unit - ) { - this(); - this.description = description; - this.start = start; - this.end = end; - this.isEpoch = isEpoch; - this.unit = unit; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Date getStart() { - return start; - } - - public void setStart(Date start) { - this.start = start; - } - - public Date getEnd() { - return end; - } - - public void setEnd(Date end) { - this.end = end; - } - - public boolean isEpoch() { - return isEpoch; - } - - public void setEpoch(boolean isEpoch) { - this.isEpoch = isEpoch; - } - - public Set getKms() { - return kms.keySet(); - } - - public void addKm(double km, SedimentLoadFraction fraction) { - kms.put(km, fraction); - } - - public SedimentLoadFraction getFraction(double km) { - SedimentLoadFraction f = kms.get(km); - if (f == null) { - f = new SedimentLoadFraction(); - kms.put(km, f); - } - return f; - } - - public void setCoarse(double km, double coarse, Range range) { - if (range == null) { - logger.error("coarse/range is null!"); - return; - } - SedimentLoadFraction f = getFraction(km); - f.setCoarse(coarse); - f.setCoarseRange(range); - } - - public void setFineMiddle(double km, double fine_middle, Range range) { - if (range == null) { - logger.error("finemiddle/range is null!"); - return; - } - SedimentLoadFraction f = getFraction(km); - f.setFineMiddle(fine_middle); - f.setFineMiddleRange(range); - } - - - public void setSand(double km, double sand, Range range) { - if (range == null) { - logger.error("sand/range is null!"); - return; - } - SedimentLoadFraction f = getFraction(km); - f.setSand(sand); - f.setSandRange(range); - } - - public void setSuspSand(double km, double susp_sand, Range range) { - if (range == null) { - logger.error("suspsand/range is null!"); - return; - } - SedimentLoadFraction f = getFraction(km); - f.setSuspSand(susp_sand); - f.setSuspSandRange(range); - } - - public void setSuspSandBed(double km, double susp_sand_bed, Range range) { - if (range == null) { - logger.error("suspsandbed/range is null!"); - return; - } - SedimentLoadFraction f = getFraction(km); - f.setSuspSandBed(susp_sand_bed); - f.setSuspSandBedRange(range); - } - - public void setSuspSediment(double km, double susp_sediment, Range range) { - if (range == null) { - logger.error("suspsed/range is null!"); - return; - } - SedimentLoadFraction f = getFraction(km); - f.setSuspSediment(susp_sediment); - f.setSuspSedimentRange(range); - } - - public void setLoadTotal(double km, double total) { - setLoadTotal(km, total, null); - } - - public void setLoadTotal(double km, double total, Range range) { - if (range == null) { - logger.error("loadtotal/range is null!"); - return; - } - SedimentLoadFraction f = getFraction(km); - f.setLoadTotal(total); - f.setLoadTotalRange(range); - } - - public void setTotal(double km, double total, Range range) { - if (range == null) { - logger.error("total/range is null!"); - return; - } - SedimentLoadFraction f = getFraction(km); - f.setTotal(total); - f.setTotalRange(range); - } - - public void setUnknown(double km, double unknown, Range range) { - if (range == null) { - logger.error("unknown/range is null!"); - return; - } - SedimentLoadFraction f = getFraction(km); - f.setUnknown(unknown); - f.setUnknownRange(range); - } - - public String getUnit() { - return unit; - } - - public void setUnit(String unit) { - this.unit = unit; - } - - public boolean hasCoarse() { - for (SedimentLoadFraction slf : kms.values()) { - if (slf.getCoarse() > 0d) { - return true; - } - } - return false; - } - - public boolean hasFineMiddle() { - for (SedimentLoadFraction slf : kms.values()) { - if (slf.getFineMiddle() > 0d) { - return true; - } - } - return false; - } - - public boolean hasSand() { - for (SedimentLoadFraction slf : kms.values()) { - if (slf.getSand() > 0d) { - return true; - } - } - return false; - } - - public boolean hasSuspSand() { - for (SedimentLoadFraction slf : kms.values()) { - if (slf.getSuspSand() > 0d) { - return true; - } - } - return false; - } - - public boolean hasSuspSediment() { - for (SedimentLoadFraction slf : kms.values()) { - if (slf.getSuspSediment() > 0d) { - return true; - } - } - return false; - } - - public boolean hasTotalLoad() { - for (SedimentLoadFraction slf : kms.values()) { - if (slf.getLoadTotal() > 0d) { - return true; - } - } - return false; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r f7f86f4e4c8d -r 963ede7b32bb artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java Wed Jul 09 17:10:18 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java Wed Jul 09 17:33:57 2014 +0200 @@ -145,8 +145,8 @@ * @param[out] resLoad resulting SedimentLoad. */ private void calculateEpochKm( - List epochLoads, - SedimentLoad resLoad, + List epochLoads, + SedimentLoadLSData resLoad, double km ) { int cSum = 0; @@ -155,7 +155,7 @@ int ssSum = 0; int ssbSum = 0; int sseSum = 0; - for (SedimentLoad load : epochLoads) { + for (SedimentLoadLSData load : epochLoads) { SedimentLoadFraction f = load.getFraction(km); if (f.getCoarse() > 0d) { double c = makeNaN0(resLoad.getFraction(km).getCoarse()); @@ -219,7 +219,7 @@ * @param i index of epoch (if multiple given). */ private SedimentLoadResult calculateEpoch(int i) { - List epochLoads = new ArrayList(); + List epochLoads = new ArrayList(); for (int j = epoch[i][0]; j <= epoch[i][1]; j++) { epochLoads.add(SedimentLoadFactory.getLoadWithData( this.river, @@ -230,10 +230,10 @@ j)); //eyear } - SedimentLoad resLoad = new SedimentLoad(); + SedimentLoadLSData resLoad = new SedimentLoadLSData(); TDoubleArrayList kms = new TDoubleArrayList(); - for (SedimentLoad load : epochLoads) { + for (SedimentLoadLSData load : epochLoads) { for (double km : load.getKms()) { if (!kms.contains(km)) { kms.add(km); @@ -247,7 +247,7 @@ resLoad.setDescription(""); resLoad.setEpoch(true); - SedimentLoad sl = calculateTotalLoad(resLoad, this.epoch[i][0]); + SedimentLoadLSData sl = calculateTotalLoad(resLoad, this.epoch[i][0]); if (this.unit.equals("m3_per_a")) { sl = calculateUnit(sl, this.epoch[i][0]); @@ -264,7 +264,7 @@ * @param i index in epochs. */ private SedimentLoadResult calculateOffEpoch(int i) { - SedimentLoad load = SedimentLoadFactory.getLoadWithData( + SedimentLoadLSData load = SedimentLoadFactory.getLoadWithData( this.river, this.yearEpoch, kmLow, @@ -272,9 +272,9 @@ this.epoch[i][0], this.epoch[i][1]); SedimentLoadResult result; - SedimentLoad sl = calculateTotalLoad(load, this.epoch[i][0]); + SedimentLoadLSData sl = calculateTotalLoad(load, this.epoch[i][0]); if (unit.equals("m3_per_a")) { - SedimentLoad slu = calculateUnit(sl, epoch[i][0]); + SedimentLoadLSData slu = calculateUnit(sl, epoch[i][0]); result = new SedimentLoadResult( this.epoch[i][0], this.epoch[i][1], @@ -296,7 +296,7 @@ * @param y year, e.g. 1980 */ private SedimentLoadResult calculateYear(int y) { - SedimentLoad load = SedimentLoadFactory.getLoadWithData( + SedimentLoadLSData load = SedimentLoadFactory.getLoadWithData( this.river, this.yearEpoch, this.kmLow, @@ -305,9 +305,9 @@ y); SedimentLoadResult result; - SedimentLoad sl = calculateTotalLoad(load, y); + SedimentLoadLSData sl = calculateTotalLoad(load, y); if (unit.equals("m3_per_a")) { - SedimentLoad slu = calculateUnit(sl, y); + SedimentLoadLSData slu = calculateUnit(sl, y); result = new SedimentLoadResult(y, 0, slu); } else { @@ -317,7 +317,7 @@ } /** Add up the loads of a year. */ - private SedimentLoad calculateTotalLoad(SedimentLoad load, int year) { + private SedimentLoadLSData calculateTotalLoad(SedimentLoadLSData load, int year) { logger.debug("calculateTotalLoad"); boolean problemThisYear = false; if (!load.hasCoarse()) { @@ -361,9 +361,9 @@ * @param load SedimentLoad to add total values (and ranges) to. * @return input param load, with total values set. */ - private SedimentLoad partialTotal(SedimentLoad load) { + private SedimentLoadLSData partialTotal(SedimentLoadLSData load) { // The load with balanced ranges, will be returned. - SedimentLoad fairLoad = load; + SedimentLoadLSData fairLoad = load; Range lastOtherRange = null; double lastOtherValue = 0d; @@ -521,7 +521,7 @@ * * @return parameter load with transformed values. */ - private SedimentLoad calculateUnit(SedimentLoad load, int year) { + private SedimentLoadLSData calculateUnit(SedimentLoadLSData load, int year) { SedimentDensity density = SedimentDensityFactory.getSedimentDensity(river, kmLow, kmUp, year); diff -r f7f86f4e4c8d -r 963ede7b32bb artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java Wed Jul 09 17:10:18 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java Wed Jul 09 17:33:57 2014 +0200 @@ -105,7 +105,7 @@ // the ranges that were added to SedimentLoad/Fraction. if (getName().equals(FacetTypes.SEDIMENT_LOAD_TA_TOTAL) ||getName().equals(FacetTypes.SEDIMENT_LOAD_M3A_TOTAL)) { - SedimentLoad load = result.getLoad(); + SedimentLoadLSData load = result.getLoad(); TDoubleArrayList xPos = new TDoubleArrayList(); TDoubleArrayList yPos = new TDoubleArrayList(); double lastX = -1d; diff -r f7f86f4e4c8d -r 963ede7b32bb artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java Wed Jul 09 17:10:18 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java Wed Jul 09 17:33:57 2014 +0200 @@ -216,7 +216,7 @@ * @param river name of river. * @param type */ - public static SedimentLoad[] getLoads( + public static SedimentLoadLSData[] getLoads( String river, String type, double startKm, @@ -237,10 +237,10 @@ if (element != null) { log.debug("SedimentLoad found in cache"); - return (SedimentLoad[])element.getValue(); + return (SedimentLoadLSData[])element.getValue(); } - SedimentLoad[] values = + SedimentLoadLSData[] values = getSedimentLoadsUncached(river, type, startKm, endKm); if (values != null && key != null) { @@ -256,7 +256,7 @@ * @param type "epoch", "off_epoch" or "single" * @return A Sedimentload filled with values from db or cache. */ - public static SedimentLoad getLoadWithData( + public static SedimentLoadLSData getLoadWithData( String river, String type, double startKm, @@ -285,10 +285,10 @@ if (element != null) { log.debug("SedimentLoad found in cache"); - return (SedimentLoad)element.getValue(); + return (SedimentLoadLSData)element.getValue(); } - SedimentLoad values = getSedimentLoadWithDataUncached( + SedimentLoadLSData values = getSedimentLoadWithDataUncached( river, type, startKm, @@ -386,7 +386,7 @@ * @param type the sediment load type (year or epoch) * @return according sediment loads. */ - public static SedimentLoad[] getSedimentLoadsUncached( + public static SedimentLoadLSData[] getSedimentLoadsUncached( String river, String type, double startKm, @@ -405,10 +405,10 @@ sqlQuery.setDouble("startKm", startKm); sqlQuery.setDouble("endKm", endKm); List results = sqlQuery.list(); - SedimentLoad[] loads = new SedimentLoad[results.size()]; + SedimentLoadLSData[] loads = new SedimentLoadLSData[results.size()]; for (int i = 0, R = results.size(); i < R; i++) { Object[] row = results.get(i); - loads[i] = new SedimentLoad( + loads[i] = new SedimentLoadLSData( (String) row[0], (Date) row[1], null, @@ -427,10 +427,10 @@ sqlQuery.setDouble("endKm", endKm); List results = sqlQuery.list(); - SedimentLoad[] loads = new SedimentLoad[results.size()]; + SedimentLoadLSData[] loads = new SedimentLoadLSData[results.size()]; for (int i = 0, R = results.size(); i < R; i++) { Object[] row = results.get(i); - loads[i] = new SedimentLoad( + loads[i] = new SedimentLoadLSData( (String) row[0], (Date) row[1], (Date) row[2], @@ -448,10 +448,10 @@ sqlQuery.setDouble("endKm", endKm); List results = sqlQuery.list(); - SedimentLoad[] loads = new SedimentLoad[results.size()]; + SedimentLoadLSData[] loads = new SedimentLoadLSData[results.size()]; for (int i = 0, R = results.size(); i < R; i++) { Object[] row = results.get(i); - loads[i] = new SedimentLoad( + loads[i] = new SedimentLoadLSData( ((Date) row[0]).toString() + (Date) row[1], (Date) row[0], (Date) row[1], @@ -463,7 +463,7 @@ else { log.warn("getSedimentLoadsUncached does not understand type " + type); } - return new SedimentLoad[0]; + return new SedimentLoadLSData[0]; } /** @@ -473,7 +473,7 @@ * * @return according sediment load. */ - public static SedimentLoad getSedimentLoadWithDataUncached( + public static SedimentLoadLSData getSedimentLoadWithDataUncached( String id, String river ) { @@ -518,13 +518,13 @@ sqlQuery.setInteger("id", Integer.valueOf(id)); List results = sqlQuery.list(); - SedimentLoad load = new SedimentLoad(); + SedimentLoadLSData load = new SedimentLoadLSData(); if (results.isEmpty()) { log.warn("Empty result for year calculation."); } else { Object[] row = results.get(0); - load = new SedimentLoad( + load = new SedimentLoadLSData( (String) row[0], //description null,//(Date) row[1], //start null, //end @@ -569,7 +569,7 @@ * * @return according sediment loads. */ - public static SedimentLoad getSedimentLoadWithDataUncached( + public static SedimentLoadLSData getSedimentLoadWithDataUncached( String river, String type, double startKm, @@ -629,13 +629,13 @@ sqlQuery.setDate("end", end.getTime()); sqlQuery.setString("grain", "total"); List results = sqlQuery.list(); - SedimentLoad load = new SedimentLoad(); + SedimentLoadLSData load = new SedimentLoadLSData(); if (results.isEmpty()) { log.warn("Empty result for year calculation."); } else { Object[] row = results.get(0); - load = new SedimentLoad( + load = new SedimentLoadLSData( (String) row[0], //description (Date) row[1], //start null, //end @@ -678,13 +678,13 @@ List results = null; results = sqlQuery.list(); - SedimentLoad load = null; + SedimentLoadLSData load = null; if (results.isEmpty()) { log.warn("No total results for off-epoch"); } else { Object[] row = results.get(0); - load = new SedimentLoad( + load = new SedimentLoadLSData( (String) row[0], (Date) row[1], (Date) row[4], @@ -705,7 +705,7 @@ load = getValues("susp_sand", sqlQuery, load, floatStations); return load; } - return new SedimentLoad(); + return new SedimentLoadLSData(); } protected static Range findMeasurementStationRange( @@ -743,10 +743,10 @@ * and values are found, return a new load. * @return param load or new load if null. */ - protected static SedimentLoad getValues ( + protected static SedimentLoadLSData getValues ( String fraction, SQLQuery query, - SedimentLoad load, + SedimentLoadLSData load, TreeMap stations ) { query.setString("grain", fraction); @@ -755,7 +755,7 @@ // We have the first results for this query, create new load. if (!results.isEmpty() && load == null) { Object[] row = results.get(0); - load = new SedimentLoad( + load = new SedimentLoadLSData( (String) row[0], (Date) row[1], (Date) row[4], @@ -790,7 +790,7 @@ /** Set a fraction value of load to given km, value and range. */ private static void setLoadFraction( - SedimentLoad load, double km, double v, Range range, String fraction) { + SedimentLoadLSData load, double km, double v, Range range, String fraction) { if (fraction.equals("coarse")) { load.setCoarse(km, v, range); } @@ -817,7 +817,7 @@ } } - public static SedimentLoad getLoadUnknown( + public static SedimentLoadLSData getLoadUnknown( String river, String description, String type @@ -837,10 +837,10 @@ if (element != null) { log.debug("SedimentLoad found in cache"); - return (SedimentLoad)element.getValue(); + return (SedimentLoadLSData)element.getValue(); } - SedimentLoad values = + SedimentLoadLSData values = getSedimentLoadUnknownUncached(river, description, type); if (values != null && key != null) { @@ -857,7 +857,7 @@ * @param type the sediment load type (year or epoch) * @return according sediment loads. */ - public static SedimentLoad getSedimentLoadUnknownUncached( + public static SedimentLoadLSData getSedimentLoadUnknownUncached( String river, String description, String type @@ -882,12 +882,12 @@ sqlQuery.setInteger("type", 0); } List results = sqlQuery.list(); - SedimentLoad load = new SedimentLoad(); + SedimentLoadLSData load = new SedimentLoadLSData(); if (results.isEmpty()) { - return new SedimentLoad(); + return new SedimentLoadLSData(); } Object[] row = results.get(0); - load = new SedimentLoad( + load = new SedimentLoadLSData( (String) row[0], (Date) row[1], (Date) row[2], @@ -909,7 +909,7 @@ * @param unit Restrict result set to those of given unit. * @param type Type like year, epoch, off_epoch */ - public static SedimentLoad[] getSedimentLoadUnknown( + public static SedimentLoadLSData[] getSedimentLoadUnknown( String river, String unit, String type) { @@ -927,10 +927,10 @@ sqlQuery.setInteger("type", 0); } List results = sqlQuery.list(); - SedimentLoad[] loads = new SedimentLoad[results.size()]; + SedimentLoadLSData[] loads = new SedimentLoadLSData[results.size()]; int counter = 0; for (Object[] row: results) { - loads[counter] = new SedimentLoad( + loads[counter] = new SedimentLoadLSData( (String)row[0], (Date)row[1], (Date)row[2], false, ""); counter++; } diff -r f7f86f4e4c8d -r 963ede7b32bb artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadLSData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadLSData.java Wed Jul 09 17:33:57 2014 +0200 @@ -0,0 +1,264 @@ +/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.artifacts.model.minfo; + +import java.util.Date; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; + +import org.dive4elements.river.artifacts.model.NamedObjectImpl; +import org.dive4elements.river.artifacts.model.Range; +import org.dive4elements.river.utils.EpsilonComparator; + +import org.apache.log4j.Logger; + + +/** Gives access to Fractions (at kms). */ +public class SedimentLoadLSData +extends NamedObjectImpl +{ + /** Private logger. */ + private static final Logger logger = Logger + .getLogger(SedimentLoadLSData.class); + + protected String description; + protected Date start; + protected Date end; + protected boolean isEpoch; + protected String unit; + + protected Map kms; + + public SedimentLoadLSData() { + kms = new TreeMap(EpsilonComparator.CMP); + } + + public SedimentLoadLSData( + String description, + Date start, + Date end, + boolean isEpoch, + String unit + ) { + this(); + this.description = description; + this.start = start; + this.end = end; + this.isEpoch = isEpoch; + this.unit = unit; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getStart() { + return start; + } + + public void setStart(Date start) { + this.start = start; + } + + public Date getEnd() { + return end; + } + + public void setEnd(Date end) { + this.end = end; + } + + public boolean isEpoch() { + return isEpoch; + } + + public void setEpoch(boolean isEpoch) { + this.isEpoch = isEpoch; + } + + public Set getKms() { + return kms.keySet(); + } + + public void addKm(double km, SedimentLoadFraction fraction) { + kms.put(km, fraction); + } + + public SedimentLoadFraction getFraction(double km) { + SedimentLoadFraction f = kms.get(km); + if (f == null) { + f = new SedimentLoadFraction(); + kms.put(km, f); + } + return f; + } + + public void setCoarse(double km, double coarse, Range range) { + if (range == null) { + logger.error("coarse/range is null!"); + return; + } + SedimentLoadFraction f = getFraction(km); + f.setCoarse(coarse); + f.setCoarseRange(range); + } + + public void setFineMiddle(double km, double fine_middle, Range range) { + if (range == null) { + logger.error("finemiddle/range is null!"); + return; + } + SedimentLoadFraction f = getFraction(km); + f.setFineMiddle(fine_middle); + f.setFineMiddleRange(range); + } + + + public void setSand(double km, double sand, Range range) { + if (range == null) { + logger.error("sand/range is null!"); + return; + } + SedimentLoadFraction f = getFraction(km); + f.setSand(sand); + f.setSandRange(range); + } + + public void setSuspSand(double km, double susp_sand, Range range) { + if (range == null) { + logger.error("suspsand/range is null!"); + return; + } + SedimentLoadFraction f = getFraction(km); + f.setSuspSand(susp_sand); + f.setSuspSandRange(range); + } + + public void setSuspSandBed(double km, double susp_sand_bed, Range range) { + if (range == null) { + logger.error("suspsandbed/range is null!"); + return; + } + SedimentLoadFraction f = getFraction(km); + f.setSuspSandBed(susp_sand_bed); + f.setSuspSandBedRange(range); + } + + public void setSuspSediment(double km, double susp_sediment, Range range) { + if (range == null) { + logger.error("suspsed/range is null!"); + return; + } + SedimentLoadFraction f = getFraction(km); + f.setSuspSediment(susp_sediment); + f.setSuspSedimentRange(range); + } + + public void setLoadTotal(double km, double total) { + setLoadTotal(km, total, null); + } + + public void setLoadTotal(double km, double total, Range range) { + if (range == null) { + logger.error("loadtotal/range is null!"); + return; + } + SedimentLoadFraction f = getFraction(km); + f.setLoadTotal(total); + f.setLoadTotalRange(range); + } + + public void setTotal(double km, double total, Range range) { + if (range == null) { + logger.error("total/range is null!"); + return; + } + SedimentLoadFraction f = getFraction(km); + f.setTotal(total); + f.setTotalRange(range); + } + + public void setUnknown(double km, double unknown, Range range) { + if (range == null) { + logger.error("unknown/range is null!"); + return; + } + SedimentLoadFraction f = getFraction(km); + f.setUnknown(unknown); + f.setUnknownRange(range); + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public boolean hasCoarse() { + for (SedimentLoadFraction slf : kms.values()) { + if (slf.getCoarse() > 0d) { + return true; + } + } + return false; + } + + public boolean hasFineMiddle() { + for (SedimentLoadFraction slf : kms.values()) { + if (slf.getFineMiddle() > 0d) { + return true; + } + } + return false; + } + + public boolean hasSand() { + for (SedimentLoadFraction slf : kms.values()) { + if (slf.getSand() > 0d) { + return true; + } + } + return false; + } + + public boolean hasSuspSand() { + for (SedimentLoadFraction slf : kms.values()) { + if (slf.getSuspSand() > 0d) { + return true; + } + } + return false; + } + + public boolean hasSuspSediment() { + for (SedimentLoadFraction slf : kms.values()) { + if (slf.getSuspSediment() > 0d) { + return true; + } + } + return false; + } + + public boolean hasTotalLoad() { + for (SedimentLoadFraction slf : kms.values()) { + if (slf.getLoadTotal() > 0d) { + return true; + } + } + return false; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r f7f86f4e4c8d -r 963ede7b32bb artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadResult.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadResult.java Wed Jul 09 17:10:18 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadResult.java Wed Jul 09 17:33:57 2014 +0200 @@ -24,7 +24,7 @@ .getLogger(SedimentLoadResult.class); protected int startYear; protected int endYear; - protected SedimentLoad load; + protected SedimentLoadLSData load; public SedimentLoadResult() { } @@ -32,14 +32,14 @@ public SedimentLoadResult( int startYear, int endYear, - SedimentLoad load + SedimentLoadLSData load ) { this.startYear = startYear; this.endYear = endYear; this.load = load; } - public SedimentLoad getLoad() { + public SedimentLoadLSData getLoad() { return this.load; } diff -r f7f86f4e4c8d -r 963ede7b32bb artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java Wed Jul 09 17:10:18 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java Wed Jul 09 17:33:57 2014 +0200 @@ -36,13 +36,13 @@ SedimentLoadAccess access = new SedimentLoadAccess(flys); String river = access.getRiverName(); String unit = access.getUnit(); - SedimentLoad[] unknown = + SedimentLoadLSData[] unknown = SedimentLoadFactory.getSedimentLoadUnknown( river, unit.replace("_per_","/"), access.getYearEpoch()); - SedimentLoad load = SedimentLoadFactory.getLoadUnknown( + SedimentLoadLSData load = SedimentLoadFactory.getLoadUnknown( river, unknown[index].getDescription(), access.getYearEpoch()); return load; } diff -r f7f86f4e4c8d -r 963ede7b32bb artifacts/src/main/java/org/dive4elements/river/artifacts/services/SedimentLoadInfoService.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/SedimentLoadInfoService.java Wed Jul 09 17:10:18 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/SedimentLoadInfoService.java Wed Jul 09 17:33:57 2014 +0200 @@ -18,7 +18,7 @@ import org.dive4elements.artifacts.CallMeta; import org.dive4elements.artifacts.GlobalContext; import org.dive4elements.artifacts.common.utils.XMLUtils; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoad; +import org.dive4elements.river.artifacts.model.minfo.SedimentLoadLSData; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFactory; @@ -69,15 +69,15 @@ return XMLUtils.newDocument(); } - SedimentLoad[] loads = + SedimentLoadLSData[] loads = SedimentLoadFactory.getLoads(river, type, fromD, toD); return buildDocument(loads); } - protected Document buildDocument(SedimentLoad[] loads) { + protected Document buildDocument(SedimentLoadLSData[] loads) { Document result = XMLUtils.newDocument(); Element all = result.createElement("sedimentloads"); - for (SedimentLoad sl : loads) { + for (SedimentLoadLSData sl : loads) { Element load = result.createElement("sedimentload"); load.setAttribute("description", sl.getDescription()); if (sl.isEpoch()) { diff -r f7f86f4e4c8d -r 963ede7b32bb artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java Wed Jul 09 17:10:18 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java Wed Jul 09 17:33:57 2014 +0200 @@ -24,7 +24,7 @@ import org.dive4elements.river.artifacts.model.DataFacet; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.ReportFacet; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoad; +import org.dive4elements.river.artifacts.model.minfo.SedimentLoadLSData; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadCalculation; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFacet; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFactory; @@ -86,8 +86,8 @@ SedimentLoadUnknownFacet f = (SedimentLoadUnknownFacet) d4e.getNativeFacet(facet, null); - SedimentLoad load = - (SedimentLoad)f.getData(artifact, null); + SedimentLoadLSData load = + (SedimentLoadLSData)f.getData(artifact, null); SedimentLoadAccess access = new SedimentLoadAccess(d4e); List dates = new ArrayList(); @@ -160,7 +160,7 @@ logger.debug("Created " + newFacets.size() + " new Facets."); String river = access.getRiverName(); - SedimentLoad[] unknown = + SedimentLoadLSData[] unknown = SedimentLoadFactory.getSedimentLoadUnknown(river, access.getUnit().replace("_per_","/"), type); diff -r f7f86f4e4c8d -r 963ede7b32bb artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java Wed Jul 09 17:10:18 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java Wed Jul 09 17:33:57 2014 +0200 @@ -21,7 +21,7 @@ import org.dive4elements.river.artifacts.access.SedimentLoadAccess; import org.dive4elements.river.artifacts.model.CalculationResult; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoad; +import org.dive4elements.river.artifacts.model.minfo.SedimentLoadLSData; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFraction; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadResult; @@ -89,7 +89,7 @@ String years = (result.getEndYear() == 0) ? result.getStartYear() + " " : result.getStartYear() + "-" + result.getEndYear(); - SedimentLoad load = result.getLoad(); + SedimentLoadLSData load = result.getLoad(); // Put load.getName()+load.getDescription()}); somewhere? for (double km: new TreeSet(load.getKms())) { SedimentLoadFraction fraction = load.getFraction(km); diff -r f7f86f4e4c8d -r 963ede7b32bb artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java Wed Jul 09 17:10:18 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java Wed Jul 09 17:33:57 2014 +0200 @@ -21,7 +21,7 @@ import org.dive4elements.river.jfree.StyledXYSeries; import org.dive4elements.river.themes.ThemeDocument; -import org.dive4elements.river.artifacts.model.minfo.SedimentLoad; +import org.dive4elements.river.artifacts.model.minfo.SedimentLoadLSData; import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFraction; // Base class for SedimantLoad$UNITProcessors @@ -49,7 +49,7 @@ FacetTypes.IS.SEDIMENT_LOAD_TA(facetName)) { points = (double[][]) data; } else if (FacetTypes.IS.SEDIMENT_LOAD_UNKNOWN(facetName)) { - SedimentLoad load = (SedimentLoad) data; + SedimentLoadLSData load = (SedimentLoadLSData) data; Set kms = load.getKms(); points = new double[2][kms.size()]; int counter = 0;