Making edits 'real'

Oct 13, 2010 at 3:41 AM

I am still mucking about in the SelectFunction.cs and have run into an issue that exposes my lack of understanding about how DotSpatial works.

I have learned to 'intercept' selected shapes and put stretch/shrink handles on the corners. When the edit is done, and the handle is released, I can make changes to the points in the Coordinate collection of the edited shape, but those edits never become 'real' onscreen; that is, the edited shape does not reflect the changes made to its coordinates.

What am I missing? How do I get changes made to _layer.Features[i] reflected on the screen?  (In case it is not obvious, _layer is the layer on which the selected shape exists and [i] is the index of the feature within that layer)


Thank you for your time,


Oct 13, 2010 at 1:34 PM
If you loaded the shape from a file, then the shape is in index mode.  This means that it is using the "ShapeIndices" and not thinking too hard about Features.  In practice we might want to switch out of index mode the minute you access the FeatureSet.Features or something, but I'm not sure if that is entirely the way I want to go.  Anyway, you can fix the problems like this:

After modifying vertices, to update the vertex array itself:

Now the vertices used for rendering should be re-created from your edited features, but if you simply invalidate the map it will just draw from the existing background image.  To invalidate the current background image you want:


Then to get the map to draw from that background image you can do:



Nov 7, 2010 at 3:56 PM

Update on this.  Someone (probably me) tried to make an optimization to make the Topology.Geometries.Point more efficient by making the "Coordinates" array created on the fly when you accessed the getter for "Coordinates".  The problem is that if you do myPointFeatureSet.Coordinates[0] = new Coordinate(), you won't have actually set anything.  I have changed this so that geometry points are heavier, but Coordinates[0] = new Coordinate(x, y) will now work correctly.