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

Altering the positions array of a feature that while it is being edited causes errors #253

Closed
jaybarra opened this issue Apr 17, 2017 · 6 comments

Comments

@jaybarra
Copy link
Contributor

jaybarra commented Apr 17, 2017

If the map is in edit mode and the feature that is being edited has its position array by adding or removing points the newly created lines will not have control points on them.

The following script will configure the map. Use a multi-point milstd line symbol for the graphic

var boundary = new emp3.api.MilStdSymbol({
  name: "Division Boundary",
  positions: [{
    latitude: 40,
    longitude: 42
  }, {
    latitude: 41,
    longitude: 43
  }, {
    latitude: 40,
    longitude: 44
  }],
  symbolCode: "GFGPGLB----I--X", // Division Boundary line
  modifiers: {
    uniqueDesignation1: "1BDE",
    uniqueDesignation2: "2BDE"
  }
});

var overlay1 = new emp3.api.Overlay({
  name: "overlay1",
  geoId: "w834mne-sdg5467-sdf-we45"
});

var editTarget = false;

var _addFeaturesToOverlay = function() {
  overlay1.addFeatures({
    features: [boundary], 
    visible: true,
    onSuccess: function() {
      map1.zoomTo({
        overlay: overlay1
      });
    }
  });
};

var _editFeature = function(feature) {
  map1.editFeature({
    feature: feature,
    onEditStart: function() {
      editTarget = feature;
    },
    onEditComplete: function() {
      editTarget = false;
    }
  });
};

var _handleFeatureClicks = function() {
  map1.addEventListener({
    eventType: emp3.api.enums.EventType.FEATURE_INTERACTION,
    callback: function(eventArgs) {
      if (eventArgs.event === emp3.api.enums.UserInteractionEventEnum.DOUBLE_CLICKED) {
        if (editTarget) {
          map1.completeEdit();
        } else {
          _editFeature(eventArgs.target[0]);
        }
      }
    }
  });
}();

var _handleMapClicks = function() {
  map1.addEventListener({
    eventType: emp3.api.enums.EventType.MAP_INTERACTION,
    callback: function(eventArgs) {
      if (eventArgs.event === emp3.api.enums.UserInteractionEventEnum.DOUBLE_CLICKED) {
        if (editTarget) {
          map1.completeEdit();
        }
      } else if (eventArgs.event === emp3.api.enums.UserInteractionEventEnum.CLICKED) {
        if (editTarget) {
          editTarget.positions.push(eventArgs.position);
          editTarget.apply();
        }
      }
    }
  });
}();

// Add the overlay to the map. 
map1.addOverlay({
  overlay: overlay1,
  onSuccess: _addFeaturesToOverlay,
  onError: function(error) {
    alert(JSON.stringify(error));
  }
});
@alberto-acevedo
Copy link
Contributor

I was able to replicate the issue. The editor manager is making a copy of the original feature. Any updates to the feature that are sent outside the editor manager are not getting detected and processed by the editor. This is why there are no control points. When the editing is committed the copy of the feature with the editing modifications overwrites any updates done to the feature while in edit mode. I found another issue when removing a feature that is getting edited, The feature remove request is sent to the engine and the feature is removed, but in the intent class it detects that the feature is in edit mode and it calls the editor manager's cancel function. The editor manager ends up re adding the original feature that was previously removed in another transaction.

There are some decisions registered in Confluence about this case:

What to do when a feature is removed during edit (https://confluence.di2e.net/display/EMP/What+to+do+when+a+feature+is+removed+during+edit )

  • If a feature or overlay remove is received while editing or drawing, it should remove the feature being edited or drawn.

What to do if an update comes for a feature under edit (https://confluence.di2e.net/display/EMP/What+to+do+when+a+feature+is+removed+during+edit )
-Item being edited should take on new values and resume editing
Map Engine checks if the update coming in is for the item being edited or drawn.
If yes to #1, the map applies the update to the feature
The map resets its view to show the udpdated feature
The map continues to allow user to edit or or draw

What should a map engine do if a plot or update has zoom set to true while in edit or draw mode (https://confluence.di2e.net/display/EMP/What+to+do+when+a+feature+is+removed+during+edit )

  • Map engine should ignore zoom parameters for feature plots while in edit and draw mode

What should a map engine do if an edit or draw command comes in if already in draw or edit mode (https://confluence.di2e.net/display/EMP/What+should+a+map+engine+do+if+an+edit+or+draw+command+comes+in+if+already+in+draw+or+edit+mode )

  • Cancel the current edit or draw, and start the new edit or draw

@alberto-acevedo
Copy link
Contributor

Test case:

Use the dev branch.

Plot an air corridor. edit the corridor. While in edit mode add an air corridor with the same identifier as the first. Then press the update button. The test is a success if the feature get updated and the control points correctly positioned. Go back to editFeature and press the commit button. The test is a success if the feature that renders on the map shows the last state of the updates to the feature.

Plot an air corridor. edit the corridor. While in edit mode add an air corridor with the same identifier as the first. Then press the update button. The test is a success if the feature get updated and the control points correctly positioned. Go back to editFeature. edit the feature once more. then press the cancel button. The test is a success if the feature that renders on the map shows the last state of the external updates to the feature.

@mubinakhan
Copy link

issue#253.PNG

@alberto-acevedo
Copy link
Contributor

What is your comment about the snapshot?

@mubinakhan
Copy link

Reintegrate

@alberto-acevedo
Copy link
Contributor

Already merged into the dev branch. closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants