fix: modifying the closed LineString

This commit fixes the bug that occurs when trying to modify
a closed LineString by clicking on the starting/ending node.

Such a closed line is added to the modify-test example.
This commit is contained in:
Fran Peručić
2015-03-25 10:44:35 +01:00
parent 7dff739bce
commit eb6d61e6d1
2 changed files with 14 additions and 2 deletions

View File

@@ -114,6 +114,7 @@ var source = new ol.source.GeoJSON(
'type': 'MultiLineString',
'coordinates': [
[[-1e6, -7.5e5], [-1e6, 7.5e5]],
[[-1e6, -7.5e5], [-1e6, 7.5e5], [-5e5, 0], [-1e6, -7.5e5]],
[[1e6, -7.5e5], [15e5, 0], [15e5, 0], [1e6, 7.5e5]],
[[-7.5e5, -1e6], [7.5e5, -1e6]],
[[-7.5e5, 1e6], [7.5e5, 1e6]]

View File

@@ -430,11 +430,22 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) {
if (ol.coordinate.equals(segment[0], vertex) &&
!componentSegments[uid][0]) {
this.dragSegments_.push([segmentDataMatch, 0]);
componentSegments[uid][0] = true;
componentSegments[uid][0] = segmentDataMatch;
} else if (ol.coordinate.equals(segment[1], vertex) &&
!componentSegments[uid][1]) {
// prevent dragging closed linestrings by the connecting node
if ((segmentDataMatch.geometry.getType() ===
ol.geom.GeometryType.LINE_STRING ||
segmentDataMatch.geometry.getType() ===
ol.geom.GeometryType.MULTI_LINE_STRING) &&
componentSegments[uid][0] &&
componentSegments[uid][0].index === 0) {
continue;
}
this.dragSegments_.push([segmentDataMatch, 1]);
componentSegments[uid][1] = true;
componentSegments[uid][1] = segmentDataMatch;
} else if (goog.getUid(segment) in this.vertexSegments_ &&
(!componentSegments[uid][0] && !componentSegments[uid][1])) {
insertVertices.push([segmentDataMatch, vertex]);