ThinkGeo.com    |     Documentation    |     Premium Support

Thematic map on PostgreFeature Layer

Hi,


I have a PostgreFeature layer, it has type/length/width  etc columns. Initially it is displayed uisng the Default LineStyle. Need to create the thematic map based on the column the user selected.


I tried the ClassBreakStyle, but the layer is invisible, what could be wrong? Here is my code:


 



   Private Function GetClassBreakRenderer() As ClassBreakStyle

        Dim lineStyle0 As New LineStyle(New GeoPen(New GeoSolidBrush(GeoColor.SimpleColors.Black), 10))
        Dim lineStyle1 As New LineStyle(New GeoPen(New GeoSolidBrush(GeoColor.SimpleColors.Red), 10))
        Dim lineStyle2 As New LineStyle(New GeoPen(New GeoSolidBrush(GeoColor.SimpleColors.Yellow), 10))
        Dim lineStyle3 As New LineStyle(New GeoPen(New GeoSolidBrush(GeoColor.SimpleColors.Green), 10))
        Dim lineStyle4 As New LineStyle(New GeoPen(New GeoSolidBrush(GeoColor.FromArgb(255, 255, 0, 255)), 10))
        Dim lineStyle5 As New LineStyle(New GeoPen(New GeoSolidBrush(GeoColor.FromArgb(255, 160, 255, 255)), 10))
        Dim lineStyle6 As New LineStyle(New GeoPen(New GeoSolidBrush(GeoColor.FromArgb(255, 128, 0, 128)), 10))
        Dim lineStyle7 As New LineStyle(New GeoPen(New GeoSolidBrush(GeoColor.FromArgb(255, 0, 128, 0)), 10))
        Dim lineStyle8 As New LineStyle(New GeoPen(New GeoSolidBrush(GeoColor.FromArgb(255, 0, 0, 255)), 10))
        Dim lineStyle9 As New LineStyle(New GeoPen(New GeoSolidBrush(GeoColor.FromArgb(255, 255, 220, 208)), 10))

        Dim clsBreakColl As New Collection(Of ClassBreak)
        clsBreakColl.Add(New ClassBreak(0, lineStyle0))
        clsBreakColl.Add(New ClassBreak(1, lineStyle1))
        clsBreakColl.Add(New ClassBreak(2, lineStyle2))
        clsBreakColl.Add(New ClassBreak(3, lineStyle3))
        clsBreakColl.Add(New ClassBreak(4, lineStyle4))
        clsBreakColl.Add(New ClassBreak(5, lineStyle5))
        clsBreakColl.Add(New ClassBreak(6, lineStyle6))
        clsBreakColl.Add(New ClassBreak(7, lineStyle7))
        clsBreakColl.Add(New ClassBreak(8, lineStyle8))
        clsBreakColl.Add(New ClassBreak(9, lineStyle9))

        ' Create class break renderer. 
        Dim breaksRender As New ClassBreakStyle("shiptype", BreakValueInclusion.IncludeValue, clsBreakColl)

        Return breaksRender
    End Function

    Private Sub mnuThematicMap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuThematicMap.Click
        Dim postgreLyr As FeatureLayer = Map1.FindFeatureLayer("PostgrePlineLayer")

        If postgreLyr Is Nothing Then
            MsgBox("Remote vessel track data is not available.")
            Exit Sub
        End If
        
        postgreLyr.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear()
        postgreLyr.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(GetClassBreakRenderer())
        Map1.Refresh()
    End Sub



Rose,


As you didn’t specify the minValue of the ClassBreakStyles, it means this style won't draw the feature which "shiptype" column value less than 0. I think probable your issues was because of all the value s in this column are smaller than 0.


So change your code a little bit like this,

 



Dim clsBreakColl As New Collection(Of ClassBreak)
clsBreakColl.Add(New ClassBreak(double.MinValue, lineStyle0))
clsBreakColl.Add(New ClassBreak(1, lineStyle1))
clsBreakColl.Add(New ClassBreak(2, lineStyle2))
clsBreakColl.Add(New ClassBreak(3, lineStyle3))
clsBreakColl.Add(New ClassBreak(4, lineStyle4))
clsBreakColl.Add(New ClassBreak(5, lineStyle5))
clsBreakColl.Add(New ClassBreak(6, lineStyle6))
clsBreakColl.Add(New ClassBreak(7, lineStyle7))
clsBreakColl.Add(New ClassBreak(8, lineStyle8))
clsBreakColl.Add(New ClassBreak(9, lineStyle9))

Thanks, 

ThinkGeo Support

 



Lee:


The "ShipType" column can only be 0 - 9, by default it is 0, I checked, there is no value is smaller than 0.


But  I changed the code like what you suggested, the thematic map still does not work.


 


Rose



Does anybody have the same problem?


Any help is greatly appreciated!


Thanks


Rose



Rose, 
  
 I tried to use your code to create a ClassBreaskStyle and it works in ShapeFileFeatureLayer in version 3.0.199.  It’s a bit hard to recreate your issue without the data source you are using.  
 Could you please try to use a ShapeFileFeatureLayer instead of PostgreFeatureLayer using the same logic to see it works or not. If it still can not work you can send us the demo with Shape File data so that we can figure it out. 
  
 Thanks, 
 ThinkGeo Support 


Lee:


I tried a Shape file, the column I used is "shiptype1", still does not work.


I will email the Shape file I used to Support, and ask them to pass it to you as it is too big to attach.


Rose


 



Rose, 
  
 Thanks for your test data. This is do a bug in GeoPen and we will fix it in the upcoming version.  
  
 For now you can use the constructor for GeoPen which pass in GeoColor and Width instead of GeoBrush and Width.  
  
 Sorry for the inconveniences for now. 
  
 Thanks, 
 ThinkGeo Support