MapWinGeoProc.SpatialOperations.MergeShapes issue

Apr 5, 2012 at 5:16 PM

Greetings,

In versions prior to 4.8, the following code would execute in just a few seconds. Now, it takes up to several minutes with the same source shapefiles.  Did something change that would cause this to occur?  Or is there a better way to handle the merging shapes?  I hope the snippet I provide is enough to generate a response, but if not, please let me know what else I should provide.  This snippet is part of a much larger routine, but I was able to narrow my problem to this code.  Thanks you in advance for any help you can provide.

Cheers,
Ken

' Get the number of selected basins
NumSelections = SelectedShapes.Count

' Merge selected shapes
If NumSelections > 1 Then
    Dim Poly1 As MapWinGIS.Shape, Poly2 As MapWinGIS.Shape
    For i = 0 To NumSelections - 1
        If i = 0 Then
            Poly1 = BasinsSf.Shape(SelectedShapes.Item(i))
            Poly2 = BasinsSf.Shape(SelectedShapes.Item(i + 1))
   
            MapWinGeoProc.SpatialOperations.MergeShapes(Poly1, Poly2, BasinPoly)
        ElseIf i > 1 And i <= NumSelections - 1 Then
            Poly1 = BasinsSf.Shape(SelectedShapes.Item(i))
            Poly2 = BasinPoly
            MapWinGeoProc.SpatialOperations.MergeShapes(Poly1, Poly2, BasinPoly)
        End If
    Next
    PolyPt = MapWinGeoProc.Utils.Centroid(BasinPoly)
End If

Apr 5, 2012 at 7:32 PM

Probably not a big deal but the Centroid is now part of the Shape class so you can do pt = shape.centroid.

 

AGP

Apr 5, 2012 at 9:22 PM

Thanks AGP.  I'll update that line, but the problem is with the MergeShapes operation.  I did a little research and found some advice suggesting that "Utils.ClipPolygon (UNION_OPERATION)" could work.  Do you have any experience using that operation? 

Cheers,
Ken

Apr 5, 2012 at 10:39 PM

No cant say I do. I would try it see if it gives you the same result.

 

AGP

Apr 6, 2012 at 6:57 PM

AGP,

The Utils.ClipPolygon operation was way faster and worked perfectly.  The merge rountine went from several minutes to about 10 seconds!  I replaced the MergeShapes line with:

BasinPoly = Utils.ClipPolygon(MapWinGIS.PolygonOperation.UNION_OPERATION, Poly1, Poly2)

note that I defined Utils earlier as New MapWinGIS.Utils

Cheers,
Ken