Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(measure): measure line should be absolutely positioned #751

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/os/interaction/measureinteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');



Expand Down Expand Up @@ -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;
};

Expand Down Expand Up @@ -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);
};
15 changes: 12 additions & 3 deletions src/plugin/cesium/interaction/cesiumdrawpolygoninteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ goog.provide('plugin.cesium.interaction.drawpolygon');

goog.require('olcs.core');
goog.require('os.interaction.DrawPolygon');
goog.require('os.webgl.AltitudeMode');


/**
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/plugin/cesium/interaction/cesiummeasureinteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');


Expand Down Expand Up @@ -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} */ (
Expand Down