]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Add property for changing pipe depth under ground with elev server 23/2923/1
authorjsimomaa <jani.simomaa@gmail.com>
Wed, 5 Jun 2019 06:17:09 +0000 (09:17 +0300)
committerjsimomaa <jani.simomaa@gmail.com>
Wed, 5 Jun 2019 06:17:09 +0000 (09:17 +0300)
gitlab #45
APROS-15308

Change-Id: I5aba84a0e712716716225a17c8953e23f97cb85d

org.simantics.maps.elevation.server.ui/src/org/simantics/maps/elevation/server/ui/MapsElevationServerPreferencePage.java
org.simantics.maps.elevation.server/META-INF/MANIFEST.MF
org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/TiffInterface.java
org.simantics.maps.elevation.server/src/org/simantics/maps/elevation/server/prefs/MapsElevationServerPreferences.java

index 69ac4bc759c9382d7f6e1a97f11f3188e0f1c94a..43200ce98a74cd07a26c87ed1625e2ce7d8eba67 100644 (file)
@@ -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);
     }
     
index 04e6dc1874195f9c3fc6a87cc9886af85fafe8b7..6ea239a4701283f14cd140e8a01e23fe345d227b 100644 (file)
@@ -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
index 14485230b9b04c99a50ce4527fb914c231008a1c..9e0a651407cd71acd1e70e587b8e0395c8a96976 100644 (file)
@@ -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;
         }
     }
index 8401aed4fafa8348ca36bdbdee9ba56506beb77d..8db89308a0e4ff1fa2cc981a31e73d2da6fbc46a 100644 (file)
@@ -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);
+    }
 }