ThinkGeo.com    |     Documentation    |     Premium Support

Advanced Editing with Shape Files

I am looking for a way to do some "advanced" editing with the shape files from the World Map Kit.  I am currently adding/deleting/updating the road shape files.  What I am looking for is a way to copy/paste/cut and undo/redo.  So if I delete a road and found it was a mistake, I would like to undo that last act.  Are there methods I can use for these or is this something that I will have to develop outside of the Map Suite?



Jake, 
  
   We don’t have any of these advanced feature in the box so to speak.  I think they could be created off of our EditInteractiveOverlay.  We have a quite powerful InteractiveOverlay system but it is semi new and we have not gotten to that kind of stuff yet.  The one thing we don’t have support for but are planning very soon is support for interacting with the keyboard as you would need this for cut, copy, past etc.  Having that in there I think it is all possible.  If this is something you want to build I suggest you take a look at the InteractiveOverlay and in the forums as to what others are doing with it.  You can also contact your sales rep to have our professional services build something like that if it is cost effective for you.  
  
   I know of a few customers doing some very advanced things by extending our EditInteractiveOverlay but it is a little tricky as these are really advanced things.  One easy approach off the top of my head would be to monitor the EditInteractiveOverlay.EditShapesLayer.  This layer houses all of the shapes and when an operation takes place it updated here.  Maybe you could get an event or subclass this layer to know when shapes come and go into this layer.  Another way would be to catch the event when vertex was moved or when a shape was updated and then capture all of the shapes in the layer.  There are a bunch of evetns when the feature is resized, moved, rotated, and when vertex as moved.  Make sure you hook into the ones with the ‘ed’ like Moved and not moving.  When you wanted to do an undo you could set the features in the layer back to what they were before and call a CreateAllControl points to force the re-creation of all of the control points.  You might be able to capture just the feature itself etc. There might be some slick ways you could do this but are a little beyond the forums. 
  
 Sorry we did’t have it packaged and ready but I think you have options. 
  
 David

Thanks, I look forward to having keyboard interaction, that will prove to be quite valuable, for other functionality than what I am looking for here.   
  
 I want to make sure I am going down the right path, is it true then that when I create a ShapeFileFeatureLayer and delete one of the features, that it was originally added to the EditInteractiveOverlay and then deleted when I called my delete function?  I am currently using the following set of commands: 
  
 street.EditTools.BeginTransaction(); 
 street.EditTools.Delete(selectedFeature.Id); 
 TransactionResult tr = street.EditTools.CommitTransaction(); 
  
 If that is going through the EditInteractiveOverlay to accomplish the display/delete, then I should be able to capture the needed events and build an in memory "journal" of what has taken place.

Jake, 
  
  
 I think I know what you mean but can you break it down step by step.  The little paragraph is hard for me to break down.  I think you are on the right track as you can get the results and make a journal.  The one thing is that the edit interactive overlay and the shapefile are very disconnected.  You know what I mean you have to take files from the shape file and put them into the edit interactive overlay.  Then when the users deletes one from the interactive overlay you need to manually go in and delete it from the shape file.  
  
 David

Thanks David, I will try to clarify.


 


The First thing I should mention is that I will need to have the undo functionality work for shapefiles, that is where the roads and other important information is that we will want the ability to undo mistakes.


I start by loading the shape files into shapefilefeaturelayers (worldmapkit that has been modified for our purposes).

I then take those shapefilefeaturelayers and allow users to modify them (add/update/delete).  Specifically this means drawing, editing and deleting roads.  

Let's take deletion as a specific example since it is the hardest to undo manually.

1. The user enters Deletion Mode.

2. The user clicks on(near) the road that they want deleted

3. I cycle through all features on the road layers to find the closest matching feature

4. If there is a feature within the range, I delete it from the shapefile.  


So really, what I was wondering, was at any time does this feature get put on the interactiveoverlay during that process?  If not, then the only time I will be able to keep a stack/journal of actions will be when I delete it manually from the shapefile.  I don't believe that is an issue, but it will at least narrow down where I start.



Hi Jake,


To implement the requirement you mentioned by EditInteractiveOverlay, you should move all the features to be modified from the shape file layer to the EditInteractiveOverlay at the beginning. Then edit or delete them and commit them to the shape file at the end.
 
For the deletion, I think it can be implemented by the following steps:
1.       Move the features to EditInteractiveOverlay,
2.       The user enters Deletion Mode,
3.       The user clicks on(near) the road that they want deleted,
4.       Loop through all features on the EditInteractiveOverlay to find the closest matching feature,
5.       If there is a feature within the range, delete it from the EditInteractiveOverlay,
6.       The user can click a button called like “Commit to Shape File” to commit all the changes to the shape file.
 
We have done a sample to implement this, and you can get it from the attachment to see if that is what you want. You can get the shape file “Austinstreets” from the HowDoISamples sample data, and you’d better back up the shape file before running this sample application.
 
For the editing, I think we can implement it like the deletion way. When put the features into the EditInteractiveOverlay, you can add vertex, remove vertex, resize, rotate and drag each feature, and then commit the modified features to the shape file.
 
For the adding, you can implement it by TrackInteraciveOverlay. For example, you can track a line shape and add it to your road shape file. We have a HowDoISamples called “Track and Edit Shape” to show how to track and edit feature.
 
Any more questions please let me know.
 
Thanks,
 
sun

1212-Post6269Demo.zip (11.9 KB)