MapWinGIS::SampleCode-InsertingPoints

This is a back-up of the WIKI.
Not all links might work
We're working on a new wiki.

Main Page | Recent changes | View source | Page history | Log in / create account |

Printable version | Disclaimers | Privacy policy

Variables RecX and RecY are the map coordinates of the point to be inserted. Other variables are defined as global in my program, for example as:

  PShape: Array[1..1000] of MapWinGIS_TLB.Shape;    // Point Shape
  NPnt: array[1..1000] of MapWinGIS_TLB.Point;
  Pnt: MapWinGIS_TLB.Point;
  Field: Array[1..20] of MapWinGIS_TLB.Field;
  SCount, PCount, FCount: integer;

The Snippet:

     if(Digitise.Checked) then
     begin
        PCount := PCount + 1;
        NPnt := CoPoint.Create;
        NPnt.x := RecX;
        NPnt.y := RecY;
        SCount := SCount + 1;
        PShape := CoShape.Create;
        PShape.ShapeType := SHP_POINT;
        PShape.Set_ShapeType(SHP_POINT);
        J := 0;
        PShape.InsertPoint(NPnt,J);  
// using '0' instead of variable J does not work: --> By Ref is required
        J := 0;
        sf.EditInsertShape(PShape,J);
        sf.EditCellValue(0,J,PID);
        sf.EditCellValue(1,J,AttribBox.Items.Strings);
        Map1.MoveLayerTop(sfCurrent-1);
     end;

I previously had dificulties making the inserted points directly visible in the MapWinGIS window visible. They only became visible after reloading the new shapefile after StopEdit.

Note the last line: "Map1.MoveLayerTop(sfCurrent-1);" with sfCurrent-1 referring to the MapWindows layer handle. Now I can see the inserted points on the fly before issuing StopEdit and reloading.

Retrieved from "http://mapwindow.org/wiki/index.php/MapWinGIS::SampleCode-InsertingPoints"

This page has been accessed 2,291 times. This page was last modified on 26 November 2005, at 17:11.