From: jsimomaa Date: Wed, 5 Jun 2019 06:17:09 +0000 (+0300) Subject: Add property for changing pipe depth under ground with elev server X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=96cdfb0ff0a6bc5dfdc4edf60a3345dd7532003e;p=simantics%2Fdistrict.git Add property for changing pipe depth under ground with elev server gitlab #45 APROS-15308 Change-Id: I5aba84a0e712716716225a17c8953e23f97cb85d --- diff --git a/org.simantics.maps.elevation.server.ui/src/org/simantics/maps/elevation/server/ui/MapsElevationServerPreferencePage.java b/org.simantics.maps.elevation.server.ui/src/org/simantics/maps/elevation/server/ui/MapsElevationServerPreferencePage.java index 69ac4bc7..43200ce9 100644 --- a/org.simantics.maps.elevation.server.ui/src/org/simantics/maps/elevation/server/ui/MapsElevationServerPreferencePage.java +++ b/org.simantics.maps.elevation.server.ui/src/org/simantics/maps/elevation/server/ui/MapsElevationServerPreferencePage.java @@ -6,6 +6,7 @@ import org.eclipse.jface.layout.GridLayoutFactory; 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; @@ -37,6 +38,9 @@ public class MapsElevationServerPreferencePage extends FieldEditorPreferencePage 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); } diff --git a/org.simantics.maps.elevation.server/META-INF/MANIFEST.MF b/org.simantics.maps.elevation.server/META-INF/MANIFEST.MF index 04e6dc18..6ea239a4 100644 --- a/org.simantics.maps.elevation.server/META-INF/MANIFEST.MF +++ b/org.simantics.maps.elevation.server/META-INF/MANIFEST.MF @@ -8,7 +8,6 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8 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 diff --git a/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/TiffInterface.java b/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/TiffInterface.java index 14485230..9e0a6514 100644 --- a/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/TiffInterface.java +++ b/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/TiffInterface.java @@ -8,6 +8,7 @@ import org.geotools.gce.geotiff.GeoTiffReader; 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; @@ -46,13 +47,27 @@ public class TiffInterface { 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; } } diff --git a/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/prefs/MapsElevationServerPreferences.java b/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/prefs/MapsElevationServerPreferences.java index 8401aed4..8db89308 100644 --- a/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/prefs/MapsElevationServerPreferences.java +++ b/org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/prefs/MapsElevationServerPreferences.java @@ -9,6 +9,7 @@ public class MapsElevationServerPreferences { 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); @@ -18,4 +19,7 @@ public class MapsElevationServerPreferences { return getPreferences().getBoolean(P_USE_ELEVATION_SERVER, false); } + public static int pipeDepthUnderGround() { + return getPreferences().getInt(P_PIPE_DEPTH_UNDER_GROUND, -1); + } }