Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsColumn.java @ 2610:3c907758f0ab
Added cacheable model for fixing column.
flys-artifacts/trunk@4192 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 03 Apr 2012 16:51:03 +0000 |
parents | |
children | b0597a63fe70 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsColumn.java Tue Apr 03 16:51:03 2012 +0000 @@ -0,0 +1,55 @@ +package de.intevation.flys.artifacts.model; + +import de.intevation.flys.artifacts.math.Linear; + +import java.util.Arrays; + +import java.io.Serializable; + +public class FixingsColumn +implements Serializable +{ + protected int columnId; + + protected double [] kms; + protected double [] ws; + + protected QRangeTree qs; + + public FixingsColumn() { + } + + public FixingsColumn( + int columnId, + double [] kms, + double [] ws + ) { + this.columnId = columnId; + this.kms = kms; + this.ws = ws; + } + + public int getColumnId() { + return columnId; + } + + public double getW(double km) { + + if (km < kms[0] || km > kms[kms.length-1]) { + return Double.NaN; + } + + int idx = Arrays.binarySearch(kms, km); + + if (idx >= 0) return ws[idx]; + + idx = -idx - 1; + + return Linear.linear(km, kms[idx], kms[idx+1], ws[idx], ws[idx+1]); + } + + public double getQ(double km) { + return qs.findQ(km); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :