01.
'Here I added the selected feature to a collection
02.
If
notesCollection.Count > 0
Then
03.
04.
WpfMap_Main.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Transparent, GeoColor.StandardColors.DarkRed)
05.
06.
WpfMap_Main.EditOverlay.EditShapesLayer.InternalFeatures.Add(notesCollection(0))
07.
08.
'I am able to see the added vertex in the EditOverlay but when I 'save it' it does not save
09.
WpfMap_Main.EditOverlay.CanAddVertex =
True
10.
WpfMap_Main.EditOverlay.CanRemoveVertex =
True
11.
WpfMap_Main.EditOverlay.CanReshape =
True
12.
WpfMap_Main.EditOverlay.CanRotate =
False
13.
WpfMap_Main.EditOverlay.CanDrag =
True
14.
15.
16.
'set the edit overlay so that its features are editable
17.
WpfMap_Main.EditOverlay.CalculateAllControlPoints()
18.
19.
End
If
20.
'##########################################
21.
22.
'in a second part of the program, this section runs after clicking a save toggle button
23.
While
i < WpfMap_Main.EditOverlay.EditShapesLayer.InternalFeatures.Count
24.
25.
Dim
newPolyShape
As
MultipolygonShape = WpfMap_Main.EditOverlay.EditShapesLayer.InternalFeatures(i).GetShape()
26.
'I added the ShapefileFeatureLayer to a 'notesList' collection
27.
'Both the index of the EditOverlay.InternalFeatures and notesCollection match the same feature
28.
'Pulling the ID from the original and assigning it to the edited feature to update
29.
newPolyShape.Id = notesList(i).Id.ToString()
30.
31.
'open the ShapeFileLayer and insert the new geometry
32.
While
(notesLayer.IsOpen)
33.
notesLayer.Close()
34.
End
While
35.
36.
notesLayer.ReadWriteMode = ShapeFileReadWriteMode.ReadWrite
37.
notesLayer.Open()
38.
notesLayer.EditTools.BeginTransaction()
39.
'insert the new shape into the feature
40.
notesLayer.EditTools.Update(newPolyShape)
41.
notesLayer.EditTools.CommitTransaction()
42.
notesLayer.Close()
43.
WpfMap_Main.EditOverlay.Close()
44.
45.
i = i + 1
46.
End
While
47.
48.
'I then clean up the collections so the next time it is ran, the indexes will match again
49.
'and then I refresh the map
50.
notesList.Clear()
51.
WpfMap_Main.EditOverlay.EditShapesLayer.InternalFeatures.Clear()
52.
WpfMap_Main.Refresh()
I have a polygon shapefile I am trying to edit. Currently, I am selecting a feature from the shapefile, adding it to the EditShapesLayer.InternalFeatures collection and setting the EditOverlay parameters so that I can add, remove, reshape, or drag the polygon. Then I calculate all the control points for the EditOverlay. I have a save button that then iterates through the EditShapesLayer.internalFeatures that grabs the shape of each internal feature, opens the shapefile, updates the feature, commits the transaction, and closes the shapefile.
Whenever I remove a vertex, reshape a polygon feature, or drag it to a new location, the update saves. However, when I try adding a vertex, it does not save. Also, on occasion, when I am double-clicking a vertex to remove it, I will get a Null Reference Exception.
I am not sure if I am missing a step or am going about this in a wrong manner. Aside from any possible syntax errors that may have resulted from copying the code across, if there a flaw in my logic somewhere? Do you have a sample that does something similar to what I am trying to accomplish?
Edit Overlay Add Vertex Not Saving
I am using the WPF Desktop Evaluation Edition 7.0 by the way.
Hi Brandon,
Thanks for your post, we tried to recreate your problem on our end, but the problem didn't show up, attached is our test sample, would you please check if there are any thing we missed?
Thanks,
Summer
006_005_004_003_002_001_sample.txt (1.41 KB)
My thoughts on how the features were stored were incorrect. I though each individual change was saved in the InternalFeatures so I was trying to iterate through for how many changes I did for the one feature. Basically, it was just a misunderstanding on my part and a simple mistake. I made it too complicated.
Thanks!
Hi Brandon,
Great to hear the problem is sorted out, if you have any more question, please feel free to let us know.
Best Regards
Summer