Interpolate2Real extends Interpolate<RealParameter, RealLiteral> implements RealParameter { @Override public Double getValue(ResultSet rs, long fid) throws ParameterException { double value = this.getLookupValue().getValue(rs, fid); if (getInterpolationPoint(0).getData() >= value) { return getInterpolationPoint(0).getValue().getValue(rs, fid); } int numPt = getNumInterpolationPoint(); if (getInterpolationPoint(numPt - 1).getData() <= value) { return getInterpolationPoint(numPt - 1).getValue().getValue(rs, fid); } int k = getFirstIP(value); InterpolationPoint<RealParameter> ip1 = getInterpolationPoint(k); InterpolationPoint<RealParameter> ip2 = getInterpolationPoint(k + 1); switch (getMode()) { case CUBIC: return cubicInterpolation(ip1.getData(), ip2.getData(), value, ip1.getValue().getValue(rs, fid), ip2.getValue().getValue(rs, fid), -1.0, -1.0); case COSINE: return cosineInterpolation(ip1.getData(), ip2.getData(), value, ip1.getValue().getValue(rs, fid), ip2.getValue().getValue(rs, fid)); case LINEAR: return linearInterpolation(ip1.getData(), ip2.getData(), value, ip1.getValue().getValue(rs, fid), ip2.getValue().getValue(rs, fid)); } return 0.0; } Interpolate2Real(RealLiteral fallback);  Interpolate2Real(InterpolateType expr); @Override Double getValue(ResultSet rs, long fid); @Override Double getValue(Map<String,Object> map); @Override void setFallbackValue(RealLiteral l); @Override void addInterpolationPoint(InterpolationPoint<RealParameter> point); @Override String toString(); @Override void setContext(RealParameterContext ctx); @Override RealParameterContext getContext(); @Override int compareTo(Object o);  }
@Test public void testLinearInterpolation() throws ParameterException { Interpolate2Real interpolate= getLinearInterpolation(); double result; interpolate.setLookupValue(new RealLiteral(1.0)); result = interpolate.getValue(null, -1); assertEquals(result, 100.0, 0.00000001); interpolate.setLookupValue(new RealLiteral(20.0)); result = interpolate.getValue(null, -1); assertEquals(result, 102.5, 0.00000001); interpolate.setLookupValue(new RealLiteral(55.0)); result = interpolate.getValue(null, -1); assertEquals(result, 155.0, 0.00000001); interpolate.setLookupValue(new RealLiteral(70.0)); result = interpolate.getValue(null, -1); assertEquals(result, 200.0, 0.00000001); }