Grid Locate

TatukGIS Internet Server Samples


 
RGB :
HEIGHT :

Source code

This TatukGIS Internet Server sample demonstrates how to use the Locate Function on an XGIS_LayerPixel layer to get information about the color and height of the selected pixel. This sample opens a ttkgp project file containing a BT (Binary Terrain) format (DTM) Digital Terrain Model file.


GridLocate.aspx    Top

                        
<%@ Register TagPrefix="ttkGIS" Namespace="TatukGIS.IS" Assembly="TatukGIS.IS" %>
<script runat="server">

    Dim GisUtils as API.XGIS_Utils

    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 )
    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 )
    End Sub

    Sub GIS_Load(sender As Object, e As EventArgs)
        GisUtils = New API.XGIS_Utils

        GIS.Open(GisUtils.GisSamplesDataDir + "samplegrid.grd")
    End Sub

    Sub GIS_Click(sender As Object, e As ImageClickEventArgs)
        Dim ptg As API.XGIS_Point
        Dim ll As API.XGIS_LayerPixel
        Dim rgbMapped As New API.XRGBTriple
        Dim nativesVals(10) As Double
        Dim bT As Boolean

        If GIS.API.IsEmpty Then Exit Sub
        ptg = GIS.API.ScreenToMap(GisUtils.Point(e.x, e.y))
        ll = GIS.API.Items.Item(0)
        If ll Is Nothing Then Exit Sub

        If ll.Locate(ptg, rgbMapped, nativesVals, bT) Then
            gridColorCell.BackColor = System.Drawing.Color.FromArgb(rgbMapped.rgbtRed, rgbMapped.rgbtGreen, rgbMapped.rgbtBlue)
            gridRGBCell.Text= String.Format("RGB :  {0} , {1} , {2}", rgbMapped.rgbtRed, rgbMapped.rgbtGreen, rgbMapped.rgbtBlue)
            gridHeightCell.Text = String.Format("HEIGHT : {0} m", nativesVals.GetValue(0))
        Else
            gridColorCell.BackColor = System.Drawing.Color.FromArgb(255,255,255)
            gridRGBCell.Text= ""
            gridHeightCell.Text = "No data"
        End If
    End Sub


</script>
<html>
<head>
    <title>TatukGIS IS LITE Sample - Locate</title>
    <link href="style.css" type="text/css" rel="stylesheet" />
</head>
<body>
    <a name="top">
    <h1>Grid Locate
    </h1>
    <h2 class="comment"><a href="../../samplesAPI.htm">TatukGIS Internet Server Samples</a>
    </h2>
    <form runat="server">
        <p>
            <br />
        </p>
        <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">
                            <p>
                                <ttkGIS:XGIS_VIEWERIS id="GIS" onclick="GIS_Click" runat="server" Height="360px" BorderColor="CornflowerBlue" BorderWidth="1px" ImageType="PNG24" OnLoad="GIS_Load" Width="300px"></ttkGIS:XGIS_VIEWERIS>
                            </p>
                        </td>
                    </tr>
                </tbody>
            </table>
        </p>
        <p>
            <asp:Table id="Table1" runat="server" BorderColor="Gray" BorderWidth="1px">
                <asp:TableRow>
                    <asp:TableCell BackColor="White" Width="300px" Font-Bold="True" HorizontalAlign="Center" Text=" " ID="gridColorCell"></asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell BackColor="White" Width="300px" Font-Bold="True" HorizontalAlign="Center" Text="RGB :" ID="gridRGBCell"></asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell BackColor="White" Width="300px" Font-Bold="True" HorizontalAlign="Center" Text="HEIGHT :" ID="gridHeightCell"></asp:TableCell>
                </asp:TableRow>
            </asp:Table>
        </p>
    </form>
    </a>
</body>
</html>