Skip to content

Commit cd1b79c

Browse files
committed
fix(cesium): fix heightReference updates as classes
clampToGround is implemented on Polyline and Primitive (polygon) not as a heightReference value but as separate classes (GroundPolylinePrimitive and GroundPrimitive). Therefore, if the heightReference changes, we cannot update those primitives and must instead recreate them.
1 parent a6f7f46 commit cd1b79c

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/os/ui/featureedit.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -1317,14 +1317,20 @@ os.ui.FeatureEditCtrl.prototype.saveGeometry_ = function(feature) {
13171317
feature.set(os.style.StyleField.ROTATION_COLUMN, '', true);
13181318
}
13191319
}
1320-
} else if (this.originalGeometry) {
1320+
} else if (this.originalGeometry && feature.getGeometry() === this.originalGeometry) {
13211321
feature.setGeometry(this.originalGeometry.clone());
13221322
}
13231323

13241324
var geom = feature.getGeometry();
1325+
13251326
if (geom) {
1326-
os.ui.FeatureEditCtrl.setGeometryRecursive(geom, os.data.RecordField.ALTITUDE_MODE, this['altitudeMode'], true);
1327-
geom.changed();
1327+
var altMode = geom.get(os.data.RecordField.ALTITUDE_MODE);
1328+
altMode = Array.isArray(altMode) && altMode.length ? altMode[0] : altMode;
1329+
1330+
if (altMode !== this['altitudeMode']) {
1331+
os.ui.FeatureEditCtrl.setGeometryRecursive(geom, os.data.RecordField.ALTITUDE_MODE, this['altitudeMode'], true);
1332+
geom.changed();
1333+
}
13281334
}
13291335
};
13301336

src/plugin/cesium/sync/featureconverter.js

+9
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,15 @@ plugin.cesium.sync.FeatureConverter.prototype.olGeometryToCesium = function(feat
17791779
return;
17801780
}
17811781

1782+
var heightReference = this.getHeightReference(context.layer, feature, geometry);
1783+
if ((heightReference !== Cesium.HeightReference.CLAMP_TO_GROUND &&
1784+
(primitive instanceof Cesium.GroundPolylinePrimitive || primitive instanceof Cesium.GroundPrimitive)) ||
1785+
(heightReference === Cesium.HeightReference.CLAMP_TO_GROUND &&
1786+
(primitive instanceof Cesium.Polyline || primitive instanceof Cesium.Primitive))) {
1787+
// we cannot update it; it must be recreated
1788+
primitive = null;
1789+
}
1790+
17821791
if (primitive && geomType != ol.geom.GeometryType.GEOMETRY_COLLECTION) {
17831792
// already exists - update it
17841793
this.updatePrimitiveLike(feature, geometry, style, context, primitive);

0 commit comments

Comments
 (0)