import org.geotools.geometry.Envelope2D;
import org.opengis.geometry.DirectPosition;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.simantics.maps.elevation.server.prefs.MapsElevationServerPreferences;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
ensureInit();
Object r = coverage.evaluate(pos);
final int dataType = coverage.getRenderedImage().getSampleModel().getDataType();
+ int pipeDepthUnderGround = MapsElevationServerPreferences.pipeDepthUnderGround();
switch (dataType) {
- case DataBuffer.TYPE_BYTE: return new Byte(((byte[]) r)[0]);
+ case DataBuffer.TYPE_BYTE: {
+ // TODO: if the result is byte how does one subtract the pipeDepth form the value?
+ // Might not be even relevant with this use case
+ return new Byte(((byte[]) r)[0]);
+ }
case DataBuffer.TYPE_SHORT: // Fall through
case DataBuffer.TYPE_USHORT: // Fall through
- case DataBuffer.TYPE_INT: return new Integer(((int[]) r)[0]);
- case DataBuffer.TYPE_FLOAT: return new Float(((float[]) r)[0]);
- case DataBuffer.TYPE_DOUBLE: return new Double(((double[]) r)[0]);
+ case DataBuffer.TYPE_INT: {
+ int val = ((int[]) r)[0] - pipeDepthUnderGround;
+ return new Integer(val);
+ }
+ case DataBuffer.TYPE_FLOAT: {
+ float val = ((float[]) r)[0] - pipeDepthUnderGround;
+ return new Float(val);
+ }
+ case DataBuffer.TYPE_DOUBLE: {
+ double val = ((double[]) r)[0] - pipeDepthUnderGround;
+ return new Double(val);
+ }
default: return null;
}
}