Shapefile Type = SHP_POINT,
I have several Points in this Point_Shapefile.
The Shape to Add is a Point.
TO DO:
-
Create a New Point, Save Shapefile or Update Shapefile to include the New Point
-
Edit the New Point (or any point in the Shapefile), by moving Point Interactively to another position, then Save.
3.Edit any Point’s Attributes using the ‘Edith Attributes’ Method, Save.
- Delete Point Shapefile.
SOLUTIONS and PROBLEMS:
-
Create New Point Shape was done easily following example by @jerryfaust(Mapwingis 5.0.1 tkCursorMode.cmEditShape)
//SUMMARY
private void BtnAddNew_Click(object sender, EventArgs e)
{
_shpfile.InteractiveEditing = true;
axMap1.CursorMode = tkCursorMode.cmAddShape;
axMap1.MapCursor = tkCursor.crsrMapDefault;
}
Point Added Successfully,
PROBLEM: New Point Shape NOT Saved when Page is Refreshed. -
Edit Point Shapefile also worked without problem.
@jerryfaust( Mapwingis 5.0.1 tkCursorMode.cmEditShape)
//SUMMARRY
private void BtnEdit_Click(object sender, EventArgs e)
{
_shpfile.InteractiveEditing = true;
axMap1.CursorMode = tkCursorMode.cmEditShape;
axMap1.MapCursor = tkCursor.crsrMapDefault;
_shpfile.Save();
}
The Point is moved successfully to another position on the map using the ‘cmEditShape’ tool.
PROBLEM: Edited Point NOT Saved when Page is Refreshed. -
Using the ‘Edit Attributes’ Example; (https://www.mapwindow.org/documentation/mapwingis4.9/_edit_attributes_8cs-example.html)
//SUMMARRY:
int layerHandle = axMap1.get_LayerHandle(0); // it’s assumed here that the layer we want to edit is the first 1 (with 0 index)
Shapefile sf = axMap1.get_Shapefile(layerHandle);
if (sf != null)
{
double projX = 0.0;
double projY = 0.0;
axMap1.PixelToProj(e.x, e.y, ref projX, ref projY);object result = null; Extents ext = new Extents(); ext.SetBounds(projX, projY, 0.0, projX, projY, 0.0); if (sf.SelectShapes(ext, 0.0, SelectMode.INCLUSION, ref result)) { int[] shapes = result as int[]; if (shapes == null) return; if (shapes.Length > 1) { string s = "More than one shapes were selected. Shape indices:"; for (int i = 0; i < shapes.Length; i++) s += shapes[i] + Environment.NewLine; MessageBox.Show(s); } else { sf.set_ShapeSelected(shapes[0], true); // selecting the shape we are about to edit axMap1.Redraw(); Application.DoEvents(); Form form = new Form(); for (int i = 0; i < sf.NumFields; i++) { System.Windows.Forms.Label label = new System.Windows.Forms.Label(); label.Left = 15; label.Top = i * 30 + 5; label.Text = sf.Field[i].Name; label.Width = 60; form.Controls.Add(label); TextBox box = new TextBox(); box.Left = 80; box.Top = label.Top; box.Width = 80; box.Text = sf.CellValue[i, shapes[0]].ToString(); box.Name = sf.Field[i].Name; form.Controls.Add(box); } form.Width = 180; form.Height = sf.NumFields * 30 + 70; Button btn = new Button { Text = "Ok", Top = sf.NumFields*30 + 10, Left = 20, Width = 70, Height = 25 }; btn.Click += BtnClick; form.Controls.Add(btn); btn = new Button { Text = "Cancel", Top = sf.NumFields*30 + 10, Left = 100, Width = 70, Height = 25 }; btn.Click += BtnClick; form.Controls.Add(btn); form.FormClosed += FormFormClosed; form.Text = "Shape: " + shapes[0]; form.ShowInTaskbar = false; form.StartPosition = FormStartPosition.CenterParent; form.FormBorderStyle = FormBorderStyle.FixedDialog; form.MaximizeBox = false; form.MinimizeBox = false; form.ShowDialog(axMap1.Parent); } } } // Execute this code if you want to save the results. // sf.StopEditingShapes(true, true, null);
Point Edited Successfully. The Attribute Table is Updated Successfully.
PROBLEM: Updated Values in the Attribute Table NOT Saved when Page is Refreshed.
- Delete Point Works without a hitch, following the MapWinGIS Example(https://www.mapwindow.org/documentation/mapwingis4.9/_remove_shape_8cs-example.html)
The Point is Deleted immediately, and the Refreshed Page indicates clearly that the Point was Deleted.
But Here is something interesting.
If the Point Shape is Added successfully using cmAddShape( which does not save) but, when I Select the EditShape Button and Click on the Newly Added Point, or move the point around, the Newly Created Point is SAVED! But the EditShape interactive Editing position of the New Point is NOT Saved. The Point goes back to the point where it was created.
Why is New Point Saved ONLY after cmEdit tool is used to select the new point?
All right folks, sorry for taking up so much of your reading time. Please I need some one kind with a little extra time on their hand to take a look at this and let me know what is I’m doing not right.
All I want done is Save.
I’ve tried
“sf.Save()” and
sf.SaveAs(@" c:\ point.shp") and
sf.StopEditingShapes(true, true, null);