import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.IWorkbench;
BooleanFieldEditor automatically = new BooleanFieldEditor(MapsElevationServerPreferences.P_USE_ELEVATION_SERVER, "Use elevation server", serverGroup);
addField(automatically);
+ IntegerFieldEditor pipeDepth = new IntegerFieldEditor(MapsElevationServerPreferences.P_PIPE_DEPTH_UNDER_GROUND, "Pipe depth under ground", serverGroup);
+ addField(pipeDepth);
+
GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).extendedMargins(12, 12, 12, 12).spacing(5, 4).applyTo(serverGroup);
}
Require-Bundle: org.simantics.district.geotools;bundle-version="1.0.0",
org.slf4j.api;bundle-version="1.7.25",
com.github.benmanes.caffeine;bundle-version="2.6.2",
- org.eclipse.jetty.util;bundle-version="9.4.5",
org.eclipse.osgi,
org.eclipse.core.runtime;bundle-version="3.13.0",
org.eclipse.equinox.preferences
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;
}
}
public static final String P_NODE = Activator.PLUGIN_ID;
public static final String P_USE_ELEVATION_SERVER = "org.simantics.maps.elevation.server.useElevationServer";
+ public static final String P_PIPE_DEPTH_UNDER_GROUND = "org.simantics.maps.elevation.server.pipeDepthUnderGround";
public static Preferences getPreferences() {
return InstanceScope.INSTANCE.getNode(MapsElevationServerPreferences.P_NODE);
return getPreferences().getBoolean(P_USE_ELEVATION_SERVER, false);
}
+ public static int pipeDepthUnderGround() {
+ return getPreferences().getInt(P_PIPE_DEPTH_UNDER_GROUND, -1);
+ }
}