Quantcast
Channel: MapWinGIS ActiveX Map and GIS Component
Viewing all articles
Browse latest Browse all 2341

New Post: Move point ?

$
0
0
Hi,

I'm trying to move a point feature with no success.

At first I tried shap.put_xy
           shpf = winmap.get_Shapefile(shpAc.hchapt)
            shap = shpf.Shape(CInt(winmap.Key)) ' get feature num
            winmap.PixelToProj(e.x, e.y, pnt.x, pnt.y)
            If shpf.StartEditingShapes(True, cbk) Then
                Dim ok As Boolean
                ok = shpf.EditingShapes ' ok, tested, works
                shap.put_XY(0, pnt.x, pnt.y) ' move point
                 shpf.StopEditingShapes(True, True, cbk)

                winmap.Refresh()
                winmap.Redraw()
            End If
This didn't work

By the way, I tried shap.Point(0)=pnt and got a memory violation. So I forgot about this one.

So I tried something else
            shpf = winmap.get_Shapefile(shpAc.hchapt)
            shap = shpf.Shape(CInt(winmap.Key))
            winmap.PixelToProj(e.x, e.y, pnt.x, pnt.y)
            If shpf.StartEditingShapes(True, cbk) Then
                Dim ok As Boolean
                ok = shpf.EditingShapes
                pnt.x += 10 ' just in case to be sure to move !!
                If shap.DeletePoint(0) Then ' delete vertice
                    If shap.InsertPoint(pnt, 0) Then ' insert new vertice
                        shpf.StopEditingShapes(True, True, cbk)
                    End If
                End If

                winmap.Refresh()
                winmap.Redraw()
            End If
This didn't work either,

So I tried (below) to delete and add shape. This works but no attributes are copied.

Any help will be appreciated !

Thanks,

Olivier
            shpf = winmap.get_Shapefile(shpAc.hchapt)
            shap = shpf.Shape(CInt(winmap.Key))
            shap.DeletePoint(0) ' delete old vertice
            winmap.PixelToProj(e.x, e.y, pnt.x, pnt.y)
            If shap.InsertPoint(pnt, 0) Then ' Insert vertice
                If shpf.StartEditingShapes(True) Then
                    shpf.EditDeleteShape(CInt(winmap.Key)) ' delete old shape
                    shpf.EditInsertShape(shap, shpf.NumShapes) ' add new
                    shpf.StopEditingShapes(True)
                    shpf.Save(cbk)
                    winmap.Refresh()
                    winmap.Redraw()
                End If
            End If

Viewing all articles
Browse latest Browse all 2341

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>