[PATCH] BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
Wald Commits
scm-commit at wald.intevation.org
Mon Mar 19 16:33:28 CET 2018
# HG changeset patch
# User mschaefer
# Date 1521473562 -3600
# Node ID 798d9dcbccddcf00bbb9065395e045d16ffa2805
# Parent 183f42641ab6f035a3a518dc9e39371ff4b4d42d
BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
diff -r 183f42641ab6 -r 798d9dcbccdd artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/BedHeightsFinder.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/BedHeightsFinder.java Mon Mar 19 14:13:37 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/BedHeightsFinder.java Mon Mar 19 16:32:42 2018 +0100
@@ -37,6 +37,12 @@
private final NavigableMap<Double, BedHeightValue> values;
+ private double meanBedHeight;
+
+ private double minBedHeight;
+
+ private double maxBedHeight;
+
/**
* Create bed height finders from a collection of bed heights.
*/
@@ -139,23 +145,53 @@
}
public double getMeanBedHeight(final double km) {
+ getBedHeights(km);
+ return this.meanBedHeight;
+ }
- if (this.values.containsKey(km))
- return this.values.get(km).getHeight();
+ public double getMinBedHeight(final double km) {
+ getBedHeights(km);
+ return this.minBedHeight;
+ }
+
+ public double getMaxBedHeight(final double km) {
+ getBedHeights(km);
+ return this.maxBedHeight;
+ }
+
+ private boolean getBedHeights(final double km) {
+ if (this.values.containsKey(km)) {
+ this.meanBedHeight = (this.values.get(km).getHeight() != null) ? this.values.get(km).getHeight().doubleValue() : Double.NaN;
+ this.minBedHeight = (this.values.get(km).getMinHeight() != null) ? this.values.get(km).getMinHeight().doubleValue() : Double.NaN;
+ this.maxBedHeight = (this.values.get(km).getMaxHeight() != null) ? this.values.get(km).getMaxHeight().doubleValue() : Double.NaN;
+ return true;
+ }
final Entry<Double, BedHeightValue> floorEntry = this.values.floorEntry(km);
final Entry<Double, BedHeightValue> ceilingEntry = this.values.ceilingEntry(km);
- if (floorEntry == null || ceilingEntry == null)
- return Double.NaN;
+ if (floorEntry == null || ceilingEntry == null) {
+ this.meanBedHeight = Double.NaN;
+ this.minBedHeight = Double.NaN;
+ this.maxBedHeight = Double.NaN;
+ return false;
+ }
- final double floorKm = floorEntry.getKey();
- final double floorHeight = floorEntry.getValue().getHeight();
- final double ceilKm = ceilingEntry.getKey();
- final double ceilHeight = ceilingEntry.getValue().getHeight();
+ final double floorKm = floorEntry.getKey().doubleValue();
+ final double ceilKm = ceilingEntry.getKey().doubleValue();
// FIXME: check if we always want that...
- return Linear.linear(km, floorKm, ceilKm, floorHeight, ceilHeight);
+ this.meanBedHeight = interpolate(km, floorKm, ceilKm, floorEntry.getValue().getHeight(), ceilingEntry.getValue().getHeight());
+ this.minBedHeight = interpolate(km, floorKm, ceilKm, floorEntry.getValue().getMinHeight(), ceilingEntry.getValue().getMinHeight());
+ this.maxBedHeight = interpolate(km, floorKm, ceilKm, floorEntry.getValue().getMaxHeight(), ceilingEntry.getValue().getMaxHeight());
+ return true;
+ }
+
+ private double interpolate(final double km, final double floorKm, final double ceilKm, final Double floorHeight, final Double ceilHeight) {
+ if ((floorHeight != null) && (ceilHeight != null))
+ return Linear.linear(km, floorKm, ceilKm, floorHeight, ceilHeight);
+ else
+ return Double.NaN;
}
}
\ No newline at end of file
diff -r 183f42641ab6 -r 798d9dcbccdd backend/src/main/java/org/dive4elements/river/model/BedHeightValue.java
--- a/backend/src/main/java/org/dive4elements/river/model/BedHeightValue.java Mon Mar 19 14:13:37 2018 +0100
+++ b/backend/src/main/java/org/dive4elements/river/model/BedHeightValue.java Mon Mar 19 16:32:42 2018 +0100
@@ -47,99 +47,111 @@
private Double uncertainty;
private Double dataGap;
private Double soundingWidth;
+ private Double minHeight;
+ private Double maxHeight;
public BedHeightValue() {
}
- public BedHeightValue(
- BedHeight bedHeight,
- Double station,
- Double height,
- Double uncertainty,
- Double dataGap,
- Double soundingWidth
- ) {
+ public BedHeightValue(final BedHeight bedHeight, final Double station, final Double height, final Double uncertainty, final Double dataGap,
+ final Double soundingWidth, final Double minHeight, final Double maxHeight) {
this.bedHeight = bedHeight;
this.station = station;
this.height = height;
this.uncertainty = uncertainty;
this.dataGap = dataGap;
this.soundingWidth = soundingWidth;
+ this.minHeight = minHeight;
+ this.maxHeight = maxHeight;
}
@Id
- @SequenceGenerator(
- name = "SEQUENCE_BED_HEIGHT_VALUE_ID_SEQ",
- sequenceName = "BED_HEIGHT_VALUES_ID_SEQ",
- allocationSize = 1)
- @GeneratedValue(
- strategy = GenerationType.SEQUENCE,
- generator = "SEQUENCE_BED_HEIGHT_VALUE_ID_SEQ")
+ @SequenceGenerator(name = "SEQUENCE_BED_HEIGHT_VALUE_ID_SEQ", sequenceName = "BED_HEIGHT_VALUES_ID_SEQ", allocationSize = 1)
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_BED_HEIGHT_VALUE_ID_SEQ")
@Column(name = "id")
public Integer getId() {
- return id;
+ return this.id;
}
- public void setId(Integer id) {
+ public void setId(final Integer id) {
this.id = id;
}
@OneToOne
@JoinColumn(name = "bed_height_id")
public BedHeight getBedHeight() {
- return bedHeight;
+ return this.bedHeight;
}
- public void setBedHeight(BedHeight bedHeight) {
+ public void setBedHeight(final BedHeight bedHeight) {
this.bedHeight = bedHeight;
}
@Column(name = "station")
public Double getStation() {
- return station;
+ return this.station;
}
- public void setStation(Double station) {
+ public void setStation(final Double station) {
this.station = station;
}
@Column(name = "height")
public Double getHeight() {
- return height;
+ return this.height;
}
- public void setHeight(Double height) {
+ public void setHeight(final Double height) {
this.height = height;
}
@Column(name="uncertainty")
public Double getUncertainty() {
- return uncertainty;
+ return this.uncertainty;
}
- public void setUncertainty(Double uncertainty) {
+ public void setUncertainty(final Double uncertainty) {
this.uncertainty = uncertainty;
}
@Column(name="data_gap")
public Double getDataGap() {
- return dataGap;
+ return this.dataGap;
}
- public void setDataGap(Double dataGap) {
+ public void setDataGap(final Double dataGap) {
this.dataGap = dataGap;
}
@Column(name="sounding_width")
public Double getSoundingWidth() {
- return soundingWidth;
+ return this.soundingWidth;
}
- public void setSoundingWidth(Double soundingWidth) {
+ public void setSoundingWidth(final Double soundingWidth) {
this.soundingWidth = soundingWidth;
}
+ @Column(name = "min_height")
+ public Double getMinHeight() {
+ return this.minHeight;
+ }
+
+ public void setMinHeight(final Double minHeight) {
+ this.minHeight = minHeight;
+ }
+
+ @Column(name = "max_height")
+ public Double getMaxHeight() {
+ return this.maxHeight;
+ }
+
+ public void setMaxHeight(final Double maxHeight) {
+ this.maxHeight = maxHeight;
+ }
+
+
public static List<BedHeightValue> getBedHeightValues(
BedHeight single) {
Session session = SessionHolder.HOLDER.get();
More information about the Dive4Elements-commits
mailing list