Join and Render

TatukGIS Internet Server Samples


Choose render expression:

Source code

This TatukGIS Internet Server sample demonstrates how to join the map to a database in order to present values from the database on the map as a colored-gradient value theme. This join operation is to a Microsoft Access database file, but the sample is also applicable to joining to SQL server database products. This sample is a replica of the DK-ActiveX JoinAndRender sample which is found in the DK Sample Set #4. The ASP.NET source code for this sample is provided below.

A reference to the ADODB interop library is required. The ADODB interop library is found in the Microsoft .NET SDK. Place the ADODB.DLL in the BIN Directory.

From the drop down menu, select either the ‘forest’ or ‘agriculture’ option. The selection of ‘forest’ color renders each polygon area based on values from the database representing the land areas used for forestry purposes. The ‘agriculture’ selection color renders each polygon to reflect the land areas used for agricultural purposes.


JoinAndRender.aspx    Top

                            
                            
                            
<%@ Page Language="VB" Debug="True" %>
<%@ Register TagPrefix="ttkGIS" Namespace="TatukGIS.IS" Assembly="TatukGIS.IS" %>
<%@ Import Namespace="ADODB" %>

<script runat="server">


    Dim GisUtils As API.XGIS_Utils
    Dim ParamsUtils As API.XGIS_ParamsUtils
    Dim ll As API.XGIS_LayerShp

    Sub GIS_FullExtent_Click(sender As Object, e As ImageClickEventArgs)
        GIS.FullExtent
    End Sub
    
    Sub GIS_ZoomIn_Click(sender As Object, e As ImageClickEventArgs)
        GIS.ZoomIn
    End Sub
    
    Sub GIS_ZoomOut_Click(sender As Object, e As ImageClickEventArgs)
        GIS.ZoomOut
    End Sub
    
    Sub GIS_Smaller_Click(sender As Object, e As ImageClickEventArgs)
        GIS.Width  = Unit.Pixel( GIS.Width.Value  - 54 )
        GIS.Height = Unit.Pixel( GIS.Height.Value - 40 )
        Legend.Height = GIS.Height
    End Sub
    
    Sub GIS_Larger_Click(sender As Object, e As ImageClickEventArgs)
        GIS.Width  = Unit.Pixel( GIS.Width.Value  + 54 )
        GIS.Height = Unit.Pixel( GIS.Height.Value + 40 )
        Legend.Height = GIS.Height
    End Sub
    
    
    Sub GIS_Load(sender As Object, e As EventArgs)
        GisUtils = New API.XGIS_Utils
        ParamsUtils = New API.XGIS_ParamsUtils
   
       'add some layers
        ll = New API.XGIS_LayerShp
        ll.Path = GisUtils.GisSamplesDataDir + "district.shp"
        ll.Name = "district"

        ll.UseConfig = False
        ll.Params.Labels.Field ="name"
        ll.Params.Labels.Pattern = API.XBrushStyle.XbsClear
        ll.Params.Labels.OutlineWidth = 0
        ll.Params.Labels.FontColor = RGB(255, 255, 255)
        ll.Params.Labels.Color = RGB(0, 0, 0)
        ll.Params.Labels.Position = API.XGIS_LabelPosition.XgisLabelPositionMiddleCenter
        ll.Params.Chart.Size = -&HFFFFFFF
        ll.Params.Render.StartSize = 350
        ll.Params.Render.EndSize = 1000

        GIS.API.Add(ll)
        GIS.ImageType = XgisImageType.PNG24   
        GIS.FullExtent()
    End Sub


    Sub GIS_BeforePaint(sender As Object, e As PaintEventArgs)
        Dim sqlDC as ADODB.Connection
        Dim sqlRS as ADODB.Recordset

        Dim vsize As String
        Dim vmin As Double
        Dim vmax As Double

        vsize = ddl_Size.Items(ddl_Size.SelectedIndex).Text

        sqlDC = new ADODB.Connection()
        sqlDC.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & GisUtils.GisSamplesDataDir & "district.mdb")

        sqlRS = new ADODB.Recordset()

        sqlRS.Open("SELECT min( " & vsize & ") AS mini, max(" & vsize & ") AS maxi FROM TDistrict", sqlDC)
        vmin = sqlRS.Fields("mini").Value
        vmax = sqlRS.Fields("maxi").Value
        sqlRS.Close()

        sqlRS.Open("select * FROM TDistrict  ORDER BY id", sqlDC)

        ll.JoinADO = sqlRS
        ll.JoinPrimary = "zone"
        ll.JoinForeign = "id"

        ll.Params.Render.Expression = vsize
        ll.Params.Render.Zones = 10
        ll.Params.Render.MinVal = vmin
        ll.Params.Render.MaxVal = vmax
        ll.Params.Render.StartColor = RGB(0, 255, 255)
        ll.Params.Render.EndColor = RGB(0, 0, 200)

        ll.Params.Area.Color = GisUtils.GIS_RENDER_COLOR
        ll.Params.Area.ShowLegend = True

    End Sub
    
    Sub Legend_Load(sender As Object, e As EventArgs)
         Legend.GIS_Viewer = GIS
    End Sub

</script>
<html>
<head>
    <title>TatukGIS Internet Server Samples</title>
    <link href="style.css" type="text/css" rel="stylesheet" />
</head>
<body>
    <a name="top"> 
    <h1>Join and Render
    </h1>
    <h2 class="comment"><a href="../../samplesAPI.htm">TatukGIS Internet Server Samples</a>
    </h2>
    <form runat="server">
        <p>
            <br />
        </p>
        <table cellspacing="0" cellpadding="0" border="0">
            <tbody>
                <tr>
                    <td>
                        <asp:ImageButton id="GIS_FullExtent" onclick="GIS_FullExtent_Click" runat="server" ImageUrl="/TatukGIS_IS8/img/fullextent.gif"></asp:ImageButton>
                        <asp:ImageButton id="GIS_ZoomIn" onclick="GIS_ZoomIn_Click" runat="server" ImageUrl="/TatukGIS_IS8/img/zoomin.gif"></asp:ImageButton>
                        <asp:ImageButton id="GIS_ZoomOut" onclick="GIS_ZoomOut_Click" runat="server" ImageUrl="/TatukGIS_IS8/img/zoomout.gif"></asp:ImageButton>
                    </td>
                    <td align="right">
                        <asp:ImageButton id="GIS_Smaller" onclick="GIS_Smaller_Click" runat="server" ImageUrl="/TatukGIS_IS8/img/smaller.gif"></asp:ImageButton>
                        <asp:ImageButton id="GIS_Larger" onclick="GIS_Larger_Click" runat="server" ImageUrl="/TatukGIS_IS8/img/larger.gif"></asp:ImageButton>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <ttkGIS:XGIS_VIEWERIS id="GIS" runat="server" Height="280px" Width="350px" OnLoad="GIS_Load" OnBeforePaint="GIS_BeforePaint" BorderColor="CornflowerBlue" BorderWidth="1px"></ttkGIS:XGIS_VIEWERIS>
                        <ttkGIS:XGIS_LegendIS id="Legend" runat="server" Width="100px" Height="280px" OnLoad="Legend_Load" BorderColor="CornflowerBlue" BorderWidth="1px" BackColor="LightSteelBlue" ImageCompression="30" BorderStyle="Solid"></ttkGIS:XGIS_LegendIS>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        Choose render expression: 
                        <asp:DropDownList id="ddl_Size" runat="server" AutoPostBack="True">
                            <asp:ListItem Value="1">agriculture</asp:ListItem>
                            <asp:ListItem Value="2">forest</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
    </a>
</body>
</html>