diff --git a/src/os/interaction/measureinteraction.js b/src/os/interaction/measureinteraction.js index 767c6797e..66f1b84e2 100644 --- a/src/os/interaction/measureinteraction.js +++ b/src/os/interaction/measureinteraction.js @@ -14,10 +14,12 @@ goog.require('ol.style.Style'); goog.require('ol.style.Text'); goog.require('os.bearing'); goog.require('os.config.Settings'); +goog.require('os.data.RecordField'); goog.require('os.feature.measure'); goog.require('os.geo2'); goog.require('os.interaction.DrawPolygon'); goog.require('os.math'); +goog.require('os.webgl.AltitudeMode'); @@ -118,6 +120,7 @@ os.interaction.Measure.prototype.getGeometry = function() { os.interaction.Measure.prototype.getProperties = function() { var props = {}; props[os.interpolate.METHOD_FIELD] = os.interaction.Measure.method; + props[os.data.RecordField.ALTITUDE_MODE] = os.webgl.AltitudeMode.ABSOLUTE; return props; }; @@ -363,3 +366,16 @@ os.interaction.Measure.prototype.onChange_ = function() { } } }; + + +/** + * @inheritDoc + */ +os.interaction.Measure.prototype.addCoord = function(coord, mapBrowserEvent) { + // the measure operation is currently only calculated over the ellipsoid surface + if (coord.length > 2) { + coord[2] = 0; + } + + os.interaction.Measure.base(this, 'addCoord', coord, mapBrowserEvent); +}; diff --git a/src/plugin/cesium/interaction/cesiumdrawpolygoninteraction.js b/src/plugin/cesium/interaction/cesiumdrawpolygoninteraction.js index d273687d2..f92fe0aa6 100644 --- a/src/plugin/cesium/interaction/cesiumdrawpolygoninteraction.js +++ b/src/plugin/cesium/interaction/cesiumdrawpolygoninteraction.js @@ -2,6 +2,7 @@ goog.provide('plugin.cesium.interaction.drawpolygon'); goog.require('olcs.core'); goog.require('os.interaction.DrawPolygon'); +goog.require('os.webgl.AltitudeMode'); /** @@ -43,10 +44,13 @@ plugin.cesium.interaction.drawpolygon.cleanupWebGL = function() { /** * Draw the polygon in Cesium. * + * @param {os.webgl.AltitudeMode=} opt_altMode Defaults to CLAMP_TO_GROUND * @this {os.interaction.DrawPolygon} * @suppress {accessControls} */ -plugin.cesium.interaction.drawpolygon.updateWebGL = function() { +plugin.cesium.interaction.drawpolygon.updateWebGL = function(opt_altMode) { + opt_altMode = opt_altMode || os.webgl.AltitudeMode.CLAMP_TO_GROUND; + if (os.MapContainer.getInstance().is3DEnabled()) { if (!this.cesiumColor) { this.cesiumColor = new Cesium.ColorGeometryInstanceAttribute( @@ -76,11 +80,16 @@ plugin.cesium.interaction.drawpolygon.updateWebGL = function() { } - this.cesiumLine = new Cesium.GroundPolylinePrimitive({ + var primClass = opt_altMode === os.webgl.AltitudeMode.CLAMP_TO_GROUND ? Cesium.GroundPolylinePrimitive : + Cesium.Primitive; + var geomClass = opt_altMode === os.webgl.AltitudeMode.CLAMP_TO_GROUND ? Cesium.GroundPolylineGeometry : + Cesium.PolylineGeometry; + + this.cesiumLine = new primClass({ asynchronous: false, appearance: new Cesium.PolylineColorAppearance(), geometryInstances: new Cesium.GeometryInstance({ - geometry: new Cesium.GroundPolylineGeometry({ + geometry: new geomClass({ positions: olcs.core.ol4326CoordinateArrayToCsCartesians(lonlats), arcType: os.interpolate.getMethod() === os.interpolate.Method.RHUMB ? Cesium.ArcType.RHUMB : Cesium.ArcType.GEODESIC, diff --git a/src/plugin/cesium/interaction/cesiummeasureinteraction.js b/src/plugin/cesium/interaction/cesiummeasureinteraction.js index 15529bb66..f0cd8ed7e 100644 --- a/src/plugin/cesium/interaction/cesiummeasureinteraction.js +++ b/src/plugin/cesium/interaction/cesiummeasureinteraction.js @@ -2,6 +2,7 @@ goog.provide('plugin.cesium.interaction.measure'); goog.require('os.interaction.DrawPolygon'); goog.require('os.interaction.Measure'); +goog.require('os.webgl.AltitudeMode'); goog.require('plugin.cesium.interaction.drawpolygon'); @@ -39,7 +40,7 @@ plugin.cesium.interaction.measure.cleanupWebGL = function() { * @suppress {accessControls} */ plugin.cesium.interaction.measure.updateWebGL = function() { - plugin.cesium.interaction.drawpolygon.updateWebGL.call(this); + plugin.cesium.interaction.drawpolygon.updateWebGL.call(this, os.webgl.AltitudeMode.ABSOLUTE); if (os.MapContainer.getInstance().is3DEnabled()) { var webgl = /** @type {plugin.cesium.CesiumRenderer|undefined} */ (