point icons on 4.8.1

Aug 7, 2012 at 1:48 AM

Hey all, I am trying to draw each point in a shapefile using a different color, size and shape based on a user's setting and not the shapefile's data. I don't see how I can use the new defaultdrawingoptions and categories to do this. I have been using 4.8.1 for a while now and it seems to work well with one small catch. I am using the deprecated set_layerpointcolor,size,shape. I also need to decide the way to draw it as soon as the user creates a new point. Right now my only solution is to loop through each shape everytime the user adds a new point add draw them accordingly using this code

    Public Sub AddPoint(ByRef Index As Integer, ByRef Color As String, ByRef MySize As Short, ByRef Shape As String, ByRef handle_Renamed As Short, ByVal MUTCDCode As String)

            Dim MyColor As System.Drawing.Color
            Dim MyShape As String

            Select Case Color
                Case "Green"
                    MyColor = System.Drawing.ColorTranslator.FromOle(&HC000)
                Case "Light Blue"
                    MyColor = System.Drawing.ColorTranslator.FromOle(&HFFFF80)
                Case "Dark Blue"
                    MyColor = System.Drawing.ColorTranslator.FromOle(&HFF0000)
                Case "Purple"
                    MyColor = System.Drawing.ColorTranslator.FromOle(&HC000C0)
                Case "Grey"
                    MyColor = System.Drawing.ColorTranslator.FromOle(&HC0C0C0)
                Case "Yellow"
                    MyColor = System.Drawing.ColorTranslator.FromOle(&HFFFF)
                Case "Red"
                    MyColor = System.Drawing.ColorTranslator.FromOle(&HFF)
                Case "Black"
                    MyColor = System.Drawing.ColorTranslator.FromOle(&H0)
            End Select

            Select Case Shape
                Case "Circle"
                    MyShape = CStr(MapWinGIS.tkPointType.ptCircle)
                Case "Diamond"
                    MyShape = CStr(MapWinGIS.tkPointType.ptDiamond)
                Case "Square"
                    MyShape = CStr(MapWinGIS.tkPointType.ptSquare)
                Case "Triangle Up"
                    MyShape = CStr(MapWinGIS.tkPointType.ptTriangleUp)
                Case "Triangle Down"
                    MyShape = CStr(MapWinGIS.tkPointType.ptTriangleDown)
                Case "Triangle Left"
                    MyShape = CStr(MapWinGIS.tkPointType.ptTriangleLeft)
                Case "Triangle Right"
                    MyShape = CStr(MapWinGIS.tkPointType.ptTriangleRight)
            End Select

            Dim col As UInteger
            col = System.Drawing.ColorTranslator.ToOle(MyColor)
            Map1.set_ShapePointColor(handle_Renamed, Index, col)
            Map1.set_ShapePointSize(handle_Renamed, Index, MySize)
            Map1.set_ShapePointType(handle_Renamed, Index, MyShape)

    End Sub

This works but takes a long time especially as the shapefile grows.

Ideally I'd like to only call this sub on the newest point added. However, doing so turns all previous points to small, black squares (presumably the default shape in 4.8.1).

Any ideas?

Aug 9, 2012 at 6:37 PM

When you are calling your routine waht fields are you using if any? The new system is much easier to use. Are there key fields that yuo base your symbology on?



Aug 9, 2012 at 6:52 PM



Unfortunately we have too many possible symbols to use the new method.  Plus, the user can change the symbology for the entire dataset without having access to the shapefile's DBF to write out the new symbology.  I think there are a few other issues too.

Aug 10, 2012 at 4:31 PM

I had many problems with using the old synatx and swicthed over to the new one and do not have the issues. But in your case if you have tons of categories then it may be too many to code. However here is how I do this for point shapes in my shapefile:

1. In a subroutine I create all the categories I need. I can also add categories as I need them. So now I have a list of categories each with their own symbology (ie size, color, shape). This routine creates the default symbology and then overlays several categories based on queries. For example the first category applies to all shapes that have [AIRPORT] = "S". Then I also add categories that are, I guess, open-ended and are just there until you apply them. these have no .Expression parameter.

2. I now have my shapefile symbolized with a default, and those that meet a query criteria get different symbology. Now I need a couple of points symbolized different and I cant use a .Expression to filter those. The .Expression currently supports limited SQL syntax. Anyway, I iterate through my shapes manually and then when I hit a shape I want to change I use shpfile.ShapeCategory(i) = catIdx. This says that shape i in the shapefile will get symbolized with category catIdx.

This works for me but yours may be more complex than this. I would take a stab of implementing the new system. Its daunting at first and I admit I hated it. But now I cant live without it.