# HG changeset patch # User Felix Wolfsteller # Date 1382015339 -7200 # Node ID 9513d1af7d58b38ea434812500f0fe9e5c05bd92 # Parent 45e3bb00ce1a055c4e9f1230d03f768ac9f6f81e Renamed artifacts/**/BedHeight(Single) to BedHeight(Single)Data, to resolve class name conflict with class in backend. diff -r 45e3bb00ce1a -r 9513d1af7d58 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java Thu Oct 17 11:12:14 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java Thu Oct 17 15:08:59 2013 +0200 @@ -66,7 +66,7 @@ BedDiffYearResult [] results = new BedDiffYearResult[heightIds.length]; for (int i = 0; i < heightIds.length; i++) { - BedHeight [] pair = getHeightPair(heightIds[i], "single"); + BedHeightData [] pair = getHeightPair(heightIds[i], "single"); results[i] = calculateYearDifference(pair); } return new CalculationResult(results, this); @@ -88,17 +88,17 @@ } /** Get two BedHeights from factory. */ - private static BedHeight [] getHeightPair(int [] ids, String type) { - return new BedHeight [] { + private static BedHeightData [] getHeightPair(int [] ids, String type) { + return new BedHeightData [] { BedHeightFactory.getHeight(type, ids[0], 0), BedHeightFactory.getHeight(type, ids[1], 0) }; } - private BedDiffEpochResult calculateEpochDifference(BedHeight[] pair) { + private BedDiffEpochResult calculateEpochDifference(BedHeightData[] pair) { - BedHeight bh1 = pair[0]; - BedHeight bh2 = pair[1]; + BedHeightData bh1 = pair[0]; + BedHeightData bh2 = pair[1]; TDoubleArrayList stations = bh1.getStations(); int size = stations.size(); @@ -125,10 +125,10 @@ return new BedDiffEpochResult(kms, diffRes, heights1, heights2, start, end); } - private BedDiffYearResult calculateYearDifference(BedHeight[] pair) { + private BedDiffYearResult calculateYearDifference(BedHeightData[] pair) { logger.debug("BedDiffCalculation.calculateYearDifference"); - BedHeightSingle s1 = (BedHeightSingle) pair[0]; - BedHeightSingle s2 = (BedHeightSingle) pair[1]; + BedHeightSingleData s1 = (BedHeightSingleData) pair[0]; + BedHeightSingleData s2 = (BedHeightSingleData) pair[1]; TDoubleArrayList stations = s1.getStations(); int size = stations.size(); diff -r 45e3bb00ce1a -r 9513d1af7d58 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeight.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeight.java Thu Oct 17 11:12:14 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +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 org.apache.log4j.Logger; - -import gnu.trove.TDoubleArrayList; -import org.dive4elements.river.artifacts.model.NamedObjectImpl; - -public class BedHeight -extends NamedObjectImpl -{ - private static Logger log = Logger.getLogger(BedHeight.class); - - protected TDoubleArrayList heights; - protected TDoubleArrayList station; - - public BedHeight() { - heights = new TDoubleArrayList(); - station = new TDoubleArrayList(); - } - - public BedHeight(String name) { - super(name); - heights = new TDoubleArrayList(); - station = new TDoubleArrayList(); - } - - public BedHeight(int capacity) { - this(capacity, ""); - } - - public BedHeight(int capacity, String name) { - super(name); - heights = new TDoubleArrayList(capacity); - station = new TDoubleArrayList(capacity); - } - - public void add(double value, double station) { - this.heights.add(value); - this.station.add(station); - } - - public int size() { - return heights.size(); - } - - public double getHeight(int idx) { - return heights.getQuick(idx); - } - - public double [] getHeights() { - return heights.toNativeArray(); - } - - public double [] get(int idx) { - return get(idx, new double [3]); - } - - public double [] get(int idx, double [] dst) { - dst[0] = heights.getQuick(idx); - dst[1] = station.getQuick(idx); - return dst; - } - - public double minHeights() { - return heights.min(); - } - - public TDoubleArrayList getStations() { - return this.station; - } - - public double getHeight(double station) { - int index = this.station.indexOf(station); - return index >= 0 ? heights.getQuick(index) : Double.NaN; - } - - - public static void removeNaNs(TDoubleArrayList [] arrays) { - - int dest = 0; - - int A = arrays.length; - int N = arrays[0].size(); - - OUTER: for (int i = 0; i < N; ++i) { - for (int j = 0; j < A; ++j) { - TDoubleArrayList a = arrays[j]; - double v = a.getQuick(i); - if (Double.isNaN(v)) { - continue OUTER; - } - a.setQuick(dest, v); - } - ++dest; - } - - if (dest < N) { - for (int i = 0; i < A; ++i) { - arrays[i].remove(dest, N-dest); - } - } - } - - public void removeNaNs() { - removeNaNs(new TDoubleArrayList [] { heights }); - } -} diff -r 45e3bb00ce1a -r 9513d1af7d58 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightData.java Thu Oct 17 15:08:59 2013 +0200 @@ -0,0 +1,115 @@ +/* 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 org.apache.log4j.Logger; + +import gnu.trove.TDoubleArrayList; +import org.dive4elements.river.artifacts.model.NamedObjectImpl; + +public class BedHeightData +extends NamedObjectImpl +{ + private static Logger log = Logger.getLogger(BedHeightData.class); + + protected TDoubleArrayList heights; + protected TDoubleArrayList station; + + public BedHeightData() { + heights = new TDoubleArrayList(); + station = new TDoubleArrayList(); + } + + public BedHeightData(String name) { + super(name); + heights = new TDoubleArrayList(); + station = new TDoubleArrayList(); + } + + public BedHeightData(int capacity) { + this(capacity, ""); + } + + public BedHeightData(int capacity, String name) { + super(name); + heights = new TDoubleArrayList(capacity); + station = new TDoubleArrayList(capacity); + } + + public void add(double value, double station) { + this.heights.add(value); + this.station.add(station); + } + + public int size() { + return heights.size(); + } + + public double getHeight(int idx) { + return heights.getQuick(idx); + } + + public double [] getHeights() { + return heights.toNativeArray(); + } + + public double [] get(int idx) { + return get(idx, new double [3]); + } + + public double [] get(int idx, double [] dst) { + dst[0] = heights.getQuick(idx); + dst[1] = station.getQuick(idx); + return dst; + } + + public double minHeights() { + return heights.min(); + } + + public TDoubleArrayList getStations() { + return this.station; + } + + public double getHeight(double station) { + int index = this.station.indexOf(station); + return index >= 0 ? heights.getQuick(index) : Double.NaN; + } + + + public static void removeNaNs(TDoubleArrayList [] arrays) { + + int dest = 0; + + int A = arrays.length; + int N = arrays[0].size(); + + OUTER: for (int i = 0; i < N; ++i) { + for (int j = 0; j < A; ++j) { + TDoubleArrayList a = arrays[j]; + double v = a.getQuick(i); + if (Double.isNaN(v)) { + continue OUTER; + } + a.setQuick(dest, v); + } + ++dest; + } + + if (dest < N) { + for (int i = 0; i < A; ++i) { + arrays[i].remove(dest, N-dest); + } + } + } + + public void removeNaNs() { + removeNaNs(new TDoubleArrayList [] { heights }); + } +} diff -r 45e3bb00ce1a -r 9513d1af7d58 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightEpoch.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightEpoch.java Thu Oct 17 11:12:14 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightEpoch.java Thu Oct 17 15:08:59 2013 +0200 @@ -12,7 +12,7 @@ public class BedHeightEpoch -extends BedHeight +extends BedHeightData { protected Date start; diff -r 45e3bb00ce1a -r 9513d1af7d58 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java Thu Oct 17 11:12:14 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java Thu Oct 17 15:08:59 2013 +0200 @@ -45,8 +45,7 @@ /* Former doc (from BedHeightAccess): * Return a {@link List} of {@link BedHeightSingleValue}s * at the range of the artifact - * @return List of {@link BedHeightSingleValue}s - */ + * @return List of {@link BedHeightSingleValue}s */ BedHeightSingle single = BedHeightSingle.getBedHeightSingleById( access.getHeightId()); return BedHeightSingleValue.getBedHeightSingleValues(single, @@ -56,8 +55,7 @@ else { /* Former doc (from BedHeightAccess): * Return the {@link BedHeight} at the height_id and time of the artifact - * @return {@link BedHeight} - */ + * @return {@link BedHeight} */ return BedHeightFactory.getHeight( access.getType(), access.getHeightId(), diff -r 45e3bb00ce1a -r 9513d1af7d58 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFactory.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFactory.java Thu Oct 17 11:12:14 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFactory.java Thu Oct 17 15:08:59 2013 +0200 @@ -64,9 +64,9 @@ /** - * Get BedHeight for given type and height_id, caring about the cache. + * Get BedHeightData for given type and height_id, caring about the cache. */ - public static BedHeight getHeight(String type, int height_id, int time) { + public static BedHeightData getHeight(String type, int height_id, int time) { log.debug("BedHeightFactory.getHeight"); Cache cache = CacheFactory.getCache(StaticBedHeightCacheKey.CACHE_NAME); @@ -77,14 +77,14 @@ Element element = cache.get(cacheKey); if (element != null) { log.debug("Got static bedheight values from cache"); - return (BedHeight)element.getValue(); + return (BedHeightData)element.getValue(); } } else { cacheKey = null; } - BedHeight values = getBedHeightUncached(type, height_id, time); + BedHeightData values = getBedHeightUncached(type, height_id, time); if (values != null && cacheKey != null) { log.debug("Store static bed height values in cache."); @@ -125,11 +125,11 @@ /** - * Get BedHeight from db. + * Get BedHeightData from db. * @param height_id database id of the bed_height * @return according BedHeight. */ - public static BedHeight getBedHeightUncached( + public static BedHeightData getBedHeightUncached( String type, int height_id, int time) @@ -141,8 +141,8 @@ Session session = SessionHolder.HOLDER.get(); SQLQuery sqlQuery = null; if (type.equals("single")) { - BedHeightSingle height = - new BedHeightSingle(getHeightName(type, height_id)); + BedHeightSingleData height = + new BedHeightSingleData(getHeightName(type, height_id)); sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE) .addScalar("height", StandardBasicTypes.DOUBLE) .addScalar("station", StandardBasicTypes.DOUBLE) @@ -182,7 +182,7 @@ } return height; } - return new BedHeight(); + return new BedHeightData(); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 45e3bb00ce1a -r 9513d1af7d58 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightSingleData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightSingleData.java Thu Oct 17 15:08:59 2013 +0200 @@ -0,0 +1,73 @@ +/* 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 gnu.trove.TDoubleArrayList; + + +public class BedHeightSingleData +extends BedHeightData +{ + protected int year; + protected TDoubleArrayList data_gap; + protected TDoubleArrayList morphWidth; + + public BedHeightSingleData() { + super(); + this.year = -1; + data_gap = new TDoubleArrayList(); + morphWidth = new TDoubleArrayList(); + } + + public BedHeightSingleData(String name) { + super(name); + this.year = -1; + data_gap = new TDoubleArrayList(); + morphWidth = new TDoubleArrayList(); + } + + public void add( + double value, + double station, + double gap, + double width, + int year + ) { + super.add(value, station); + this.year = year; + this.data_gap.add(gap); + this.morphWidth.add(width); + } + + public int getYear() { + return this.year; + } + + public double getMorphWidth(int idx) { + return this.morphWidth.getQuick(idx); + } + + public double getDataGap(int idx) { + return this.data_gap.getQuick(idx); + } + + public double getMorphWidth(double station) { + int index = this.station.indexOf(station); + return index >= 0 ? morphWidth.getQuick(index): Double.NaN; + } + + public double getDataGap(double station) { + int index = this.station.indexOf(station); + return index >= 0 ? data_gap.getQuick(index) : Double.NaN; + } + + public double[] getMorphWidths() { + return this.morphWidth.toNativeArray(); + } +} diff -r 45e3bb00ce1a -r 9513d1af7d58 artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightProcessor.java Thu Oct 17 11:12:14 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightProcessor.java Thu Oct 17 15:08:59 2013 +0200 @@ -15,7 +15,7 @@ import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifacts.CallContext; -import org.dive4elements.river.artifacts.model.minfo.BedHeightSingle; +import org.dive4elements.river.artifacts.model.minfo.BedHeightSingleData; import org.dive4elements.river.exports.XYChartGenerator; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.jfree.StyledXYSeries; @@ -62,8 +62,8 @@ Object data = bundle.getData(context); XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); - if (data instanceof BedHeightSingle) { - BedHeightSingle bData = (BedHeightSingle)data; + if (data instanceof BedHeightSingleData) { + BedHeightSingleData bData = (BedHeightSingleData)data; double[] width = bData.getMorphWidths(); double[] stations = bData.getStations().toNativeArray(); diff -r 45e3bb00ce1a -r 9513d1af7d58 artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightSoundingProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightSoundingProcessor.java Thu Oct 17 11:12:14 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightSoundingProcessor.java Thu Oct 17 15:08:59 2013 +0200 @@ -15,7 +15,7 @@ import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifacts.CallContext; -import org.dive4elements.river.artifacts.model.minfo.BedHeightSingle; +import org.dive4elements.river.artifacts.model.minfo.BedHeightSingleData; import org.dive4elements.river.exports.XYChartGenerator; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.jfree.StyledXYSeries; @@ -62,8 +62,8 @@ Object data = bundle.getData(context); XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); - if (data instanceof BedHeightSingle) { - BedHeightSingle bData = (BedHeightSingle)data; + if (data instanceof BedHeightSingleData) { + BedHeightSingleData bData = (BedHeightSingleData)data; double[] width = bData.getMorphWidths(); double[] stations = bData.getStations().toNativeArray();