diff --git a/src/ol/feature.js b/src/ol/feature.js
index caebeb56c5..38da602d17 100644
--- a/src/ol/feature.js
+++ b/src/ol/feature.js
@@ -42,6 +42,13 @@ ol.Feature = function(opt_values) {
*/
this.geometryName_;
+ /**
+ * Original of this feature when it was modified.
+ * @type {ol.Feature}
+ * @private
+ */
+ this.original_ = null;
+
/**
* The render intent for this feature.
* @type {ol.layer.VectorLayerRenderIntent|string}
@@ -101,6 +108,15 @@ ol.Feature.prototype.getGeometry = function() {
};
+/**
+ * Get the original of this feature when it was modified.
+ * @return {ol.Feature} Original.
+ */
+ol.Feature.prototype.getOriginal = function() {
+ return this.original_;
+};
+
+
/**
* Get any symbolizers set directly on the feature.
* @return {Array.
} Symbolizers (or null if none).
@@ -176,6 +192,15 @@ ol.Feature.prototype.setGeometry = function(geometry) {
};
+/**
+ * Set the original of this feature when it was modified.
+ * @param {ol.Feature} original Original.
+ */
+ol.Feature.prototype.setOriginal = function(original) {
+ this.original_ = original;
+};
+
+
/**
* Gets the renderIntent for this feature.
* @return {string} Render intent.
diff --git a/src/ol/interaction/modifyinteraction.js b/src/ol/interaction/modifyinteraction.js
index 1aa7b2335e..98c1fed05a 100644
--- a/src/ol/interaction/modifyinteraction.js
+++ b/src/ol/interaction/modifyinteraction.js
@@ -172,7 +172,8 @@ ol.interaction.Modify.prototype.addSegments_ =
ol.interaction.Modify.prototype.handleDragStart = function(evt) {
this.dragSegments_ = [];
for (var i = 0, ii = this.layers_.length; i < ii; ++i) {
- var selectionData = this.layers_[i].getSelectionData();
+ var layer = this.layers_[i];
+ var selectionData = layer.getSelectionData();
var selectionLayer = selectionData.layer;
if (!goog.isNull(selectionLayer)) {
var editData = selectionLayer.getEditData();
@@ -186,16 +187,22 @@ ol.interaction.Modify.prototype.handleDragStart = function(evt) {
for (var j = 0, jj = segments.length; j < jj; ++j) {
var segmentData = segments[j];
var segment = segmentData[0];
+ var feature = segmentData[1];
+ var featureId = goog.getUid(feature);
+ var original = selectionData.featuresBySelectedFeatureUid[featureId];
if (vertexFeature.renderIntent ==
ol.layer.VectorLayerRenderIntent.TEMPORARY) {
if (ol.coordinate.equals(segment[0], vertex)) {
this.dragSegments_.push([selectionLayer, segmentData, 0]);
- } else {
+ feature.setOriginal(original);
+ } else if (ol.coordinate.equals(segment[1], vertex)) {
this.dragSegments_.push([selectionLayer, segmentData, 1]);
+ feature.setOriginal(original);
}
} else if (
ol.coordinate.squaredDistanceToSegment(vertex, segment) === 0) {
insertVertices.push([selectionLayer, segmentData, vertex]);
+ feature.setOriginal(original);
}
}
for (j = insertVertices.length - 1; j >= 0; --j) {