Shapefile editing

Functions

int Shapefile.EditAddShape (Shape shape)
 Adds a new shape to the shapefile. More...
 
bool Shapefile.EditClear ()
 Deletes all the shapes from the shapefile. More...
 
bool Shapefile.EditDeleteShape (int shapeIndex)
 Deletes a shape from the shapefile. More...
 
bool Shapefile.EditInsertShape (Shape shape, ref int shapeIndex)
 Inserts a new shape in the shapefile. More...
 
bool Shapefile.EditUpdateShape (int shapeIndex, Shape shpNew)
 Substitutes shape at specified index with another instance. More...
 
bool Shapefile.get_ShapeModified (int shapeIndex)
 Gets a value indicating whether particular shape was modified after shapefile was opened. More...
 
void Shapefile.set_ShapeModified (int shapeIndex, bool newVal)
 Sets a value indicating whether particular shape was modified after shapefile was opened. More...
 
bool Shapefile.StartEditingShapes (bool startEditTable, ICallback cBack)
 Starts editing mode for the shapefile. More...
 
bool Shapefile.StopEditingShapes (bool applyChanges, bool stopEditTable, ICallback cBack)
 Stops editing modes for the shapefile and optionally saves the changes. More...
 

Properties

bool Shapefile.EditingShapes [get]
 Gets the value indicating whether editing operations are allowed for shapefile. More...
 
bool Shapefile.InteractiveEditing [get, set]
 Gets or sets a value indicating whether a shapefile can be edited with built-in interactive tools. More...
 
bool Shapefile.Snappable [get, set]
 Gets or sets a value indicating whether interactive editing tools can snap to vertices of the shapefile. More...
 
bool Shapefile.Volatile [get, set]
 Gets or sets a value indicating whether shapefile can be redrawn without redrawing other layer on the map. More...
 

Detailed Description

Here is a list of properties and methods which control the editing of shapefile. This module is a part of the documentation of Shapefile class.

dot_inline_dotgraph_27.png

Graph description

Function Documentation

◆ EditAddShape()

int Shapefile.EditAddShape ( Shape  shape)

Adds a new shape to the shapefile.

Parameters
shapeThe shape to be added.
Returns
The index of the new shape or -1 on failure.
Examples
IntersectionLength.cs, and Segmentation.cs.

◆ EditClear()

bool Shapefile.EditClear ( )

Deletes all the shapes from the shapefile.

Both shapefile and attribute table must be in editing mode for the successful operation. The records of attribute table will be removed as well to ensure shapefile integrity.

Returns
Returns true on success and false otherwise.

◆ EditDeleteShape()

bool Shapefile.EditDeleteShape ( int  shapeIndex)

Deletes a shape from the shapefile.

Both shapefile and attribute table must be in editing mode for the successful operation. Corresponding record will be removed from attribute table to ensure shapefile integrity. Indices of shapes after the deleted one will be decreased by 1 after the operation.

Parameters
shapeIndexThe index of shape to delete.
Returns
Returns true on success and false otherwise.
See also
Shapefile.EditingShapes, Shapefile.EditingTable
Examples
RemoveShape.cs.

◆ EditInsertShape()

bool Shapefile.EditInsertShape ( Shape  shape,
ref int  shapeIndex 
)

Inserts a new shape in the shapefile.

Both shapefile and attribute table must be in editing mode for the successful operation. A record will be automatically added to the attribute table to ensure shapefile integrity.

Parameters
shapeThe shape object to insert.
shapeIndexThe index to insert the new shape at. An invalid index will be automatically substituted with closest allowable value without reporting the error.
Returns
True on success and false otherwise.
Examples
CreateBuffer.cs, LinePattern.cs, MarkPoints.cs, and SplitByAttribute.cs.

◆ EditUpdateShape()

bool Shapefile.EditUpdateShape ( int  shapeIndex,
Shape  shpNew 
)

Substitutes shape at specified index with another instance.

The method doesn't affect attribute table values.

Parameters
shapeIndexIndex of shape to substitute.
shpNewNew shape to substitute an existing one with.
Returns
True on success.
New API 4.9.3:
Added in version 4.9.3

◆ get_ShapeModified()

bool Shapefile.get_ShapeModified ( int  shapeIndex)

Gets a value indicating whether particular shape was modified after shapefile was opened.

Parameters
shapeIndexIndex of shape.
Returns
The value of modified flag.

This property is used by OgrLayer.SaveChanges method to determine shape records to be updated in datasource. The flag is set to true automatically only on insertion of a new shape. For other types of edits (editing of vertices, editing of attributes) the flag must be set in the client code.

New API 4.9.3:
Added in version 4.9.3

◆ set_ShapeModified()

void Shapefile.set_ShapeModified ( int  shapeIndex,
bool  newVal 
)

Sets a value indicating whether particular shape was modified after shapefile was opened.

This property is used by OgrLayer.SaveChanges method to determine shape records to be updated in datasource. The flag is set to true automatically only on insertion of a new shape. For other types of edits (editing of vertices, editing of attributes) the flag must be set in the client code.

Parameters
shapeIndexIndex of shape.
newValNew value of modified flag.
Returns
New value of modified flag.
New API 4.9.3:
Added in version 4.9.3

◆ StartEditingShapes()

bool Shapefile.StartEditingShapes ( bool  startEditTable,
ICallback  cBack 
)

Starts editing mode for the shapefile.

In case editing mode has already been opened the new call will return true which is different from the behaviour of the earlier versions (before 4.8).

Parameters
startEditTableA value which indicate whether or not the editing mode will be opened for attribute table associated with the shapefile.
cBackA callback object to report errors and progress information.
Returns
Returns true on successful opening of the editing mode and false on failure.
Examples
IntersectionLength.cs, MinimalDistance.cs, SelectBox.cs, and ToolTip.cs.

◆ StopEditingShapes()

bool Shapefile.StopEditingShapes ( bool  applyChanges,
bool  stopEditTable,
ICallback  cBack 
)

Stops editing modes for the shapefile and optionally saves the changes.

Parameters
applyChangesThe value which indicates whether changes made to the shapefile should be saved.
stopEditTableThe value which indicates whether editing mode for associated attribute table should be closed as well.
cBackA callback object to report errors and progress information.
Returns
True on success and false otherwise.
Examples
MinimalDistance.cs.

Properties

◆ EditingShapes

bool Shapefile.EditingShapes
get

Gets the value indicating whether editing operations are allowed for shapefile.

Shapefile.EditInsertShape, Shapefile.EditDeleteShape, Shapefile.EditClear are affected by this property.
Use Shapefile.StartEditingShapes and Shapefile.StopEditingShapes to control the editing mode.

◆ InteractiveEditing

bool Shapefile.InteractiveEditing
getset

Gets or sets a value indicating whether a shapefile can be edited with built-in interactive tools.

Setting the property to true will automatically call Shapefile.StartEditingShapes if shapefile hasn't been loaded in the memory already. Setting it false won't call Shapefile.StopEditingShapes, only interactive tools will be disabled. Interactive editing mode automatically sets Shapefile.Volatile property to true.

See also
ShapeEditor, AxMap.CursorMode
New API 4.9.3:
Added in version 4.9.3

◆ Snappable

bool Shapefile.Snappable
getset

Gets or sets a value indicating whether interactive editing tools can snap to vertices of the shapefile.

New API 4.9.3:
Added in version 4.9.3

◆ Volatile

bool Shapefile.Volatile
getset

Gets or sets a value indicating whether shapefile can be redrawn without redrawing other layer on the map.

All volatile shapefiles will be placed in main screen buffer (along with drawing layers) rather than data layer buffer, so that their redraw can be forced with AxMap.Redraw2(tkRedrawType.RedrawSkipDataLayers). This can be recommended for in-memory shapefiles with constantly changing values to ensure rendering performance.

New API 4.9.2:
Added in version 4.9.2
Examples
TrackCars.cs.