Knowledge Base





KB10734 - Programmatically move or delete a point (vertex) forming a shape.

A shape cannot be edited directly. The points forming the shape must first be copied to some array or temporary shape (such as GopyGeometry) that is editable. Alternatively, the DK GIS.Editor class can be used with the DeletePoint, AddPoint, MovePoint and InsertPoint interfaces. The Editor class uses an internal array for this.

For example (parts are numbered from 0):

   TatukGIS_DK.IXGIS_Utils GisUtils = new TatukGIS_DK.XGIS_UtilsClass();

   private void button1_Click(object sender, System.EventArgs e)
   {
     TatukGIS_DK.XGIS_LayerVector lv;

     lv = GIS.Get( "states" ) as TatukGIS_DK.XGIS_LayerVector;

     TatukGIS_DK.IXGIS_Shape shp = lv.FindFirst( lv.Extent, "", null, "", true);

     shp = shp.MakeEditable() ;

     GIS.Editor.EditShape( shp, 0 ) ;
     GIS.Editor.MovePoint( 1, GisUtils.GisPoint(100,100) ) ;
     GIS.Editor.EndEdit() ;

     shp.Invalidate( true );
   }

The following sample code moves a whole shape vertically by 100 km (tested on our „states.shp” data). Note that operating points are counted from (1) while shapes and parts are counted from (0). Generally, it is done this way to solve “select position before the start of the shape” issue.

private void button1_Click(object sender, System.EventArgs e)
{
   TatukGIS_DK.XGIS_LayerVector lv;

   lv = GIS.Get( "test" ) as TatukGIS_DK.XGIS_LayerVector;

   TatukGIS_DK.IXGIS_Shape shp = lv.FindFirst( lv.Extent, "", null, "", true);

   shp = shp.MakeEditable() ;

   GIS.Editor.EditShape( shp, 0 ) ;

   for (int i=0;i    {
     GIS.Editor.MovePoint( i+1, GisUtils.GisPoint( GIS.Editor.get_Point(i).X+100000,GIS.Editor.get_Point(i).Y ) );    }
   GIS.Editor.EditEdit( shp ) ;

   shp.Invalidate( true );

Created: November 30, 2006, Modified: December 29, 2015