select.aspx Top
<%@ Page Language="VB" Debug="True" %>
<%@ Register TagPrefix="ttkGIS" Namespace="TatukGIS.IS" Assembly="TatukGIS.IS" %>
<script runat="server">
Dim GisUtils As API.XGIS_Utils
Sub Page_Load(sender As Object, e As EventArgs)
If not Page.IsPostBack then
Table_Desc.Visible = True
Lbl_Desc_1.Visible = True
Lbl_Desc_2.Visible = True
Lbl_Desc_1.Text = "Select by line:"
Lbl_Desc_2.Text = "Click first Point"
end if
End Sub
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
Dim ll As API.XGIS_LayerSHP
Dim ll1 As API.XGIS_LayerVector
'add new layers
ll = New API.XGIS_LayerSHP
ll.OutCodePage = 1250
ll.Path = GisUtils.GisSamplesDataDir + "states.shp"
ll.Name = "states"
ll.UseConfig = False
ll.Params.Area.OutlineWidth = 2
ll.Params.Area.OutlineColor = RGB(100, 100, 100)
ll.Params.Area.Color = RGB(180, 220, 180)
GIS.API.Add(ll)
'add new layers
ll = New API.XGIS_LayerSHP
ll.Path = GisUtils.GisSamplesDataDir + "rivers.shp"
ll.Name = "rivers"
ll.UseConfig = False
ll.Params.Line.Color=RGB(70,150,190)
ll.Params.Line.Width=-2
GIS.API.Add(ll)
ll1 = New API.XGIS_LayerVector
ll1.Name = "points"
GIS.API.Add(ll1)
ll1 = New API.XGIS_LayerVector
ll1.Name = "buffers"
GIS.API.Add(ll1)
'set full extent
GIS.FullExtent()
GIS.Zoom = GIS.Zoom * 2
GIS.ImageType = XgisImageType.PNG24
GIS.Api.SelectionColor=System.Convert.ToUInt32(RGB(255,255,0))
GIS.Api.SelectionTransparency=60
End Sub
Sub GIS_Options_SelectedIndexChanged(sender As Object, e As EventArgs)
Unselect_All()
Select Case GIS_Options.SelectedItem.Value
Case 1
Table_Desc.Visible = True
Lbl_Desc_1.Visible = True
Lbl_Desc_2.Visible = True
Lbl_Desc_1.Text = "Select by line:"
Lbl_Desc_2.Text = "Click first Point"
Case 2
Table_Desc.Visible = True
Lbl_Desc_1.Visible = True
Lbl_Desc_2.Visible = True
Lbl_Desc_1.Text = "Select by circle:"
Lbl_Desc_2.Text = "Click first Point"
Case 3
Table_Desc.Visible = True
Lbl_Desc_1.Visible = True
Lbl_Desc_2.Visible = True
Lbl_Desc_1.Text = "Select by rectangle:"
Lbl_Desc_2.Text = "Click first Point"
End select
End Sub
Sub Unselect_All()
session("point_1") = Nothing
session("point_2") = Nothing
Table_Desc.Visible = False
Lbl_Desc_1.Visible = False
Lbl_Desc_2.Visible = False
Lbl_Desc_1.Text = ""
Lbl_Desc_2.Text = ""
StatesList.Visible = False
End Sub
Sub GIS_Paint(sender As Object, e As PaintEventArgs)
if Page.IsPostBack then
'draw a polygon if necessary
DrawSelectedPoly()
end if
GIS.Draw()
End Sub
Sub GIS_Click(sender As Object, e As ImageClickEventArgs)
GIS_GetPoints(sender, e)
End Sub
Sub GIS_GetPoints(sender As Object, e As ImageClickEventArgs)
dim p As API.XPoint
dim p_gis As API.XGIS_Point
if session("point_1") Is Nothing
'create first point
Lbl_Desc_2.Text = "Click second point"
p = GisUtils.Point(e.X, e.Y )
p_gis = GIS.API.ScreenToMap(p)
session("point_1") = GisUtils.GisPoint( p_gis.X, p_gis.Y )
else
'create second point
p = GisUtils.Point(e.X, e.Y )
p_gis = GIS.API.ScreenToMap(p)
session("point_2") = GisUtils.GisPoint( p_gis.X, p_gis.Y )
end if
End sub
Sub DrawSelectedPoly()
Dim lshp, shp, pshp, cshp as API.XGIS_Shape
Dim pll as API.XGIS_LayerVector
dim p1, p2, cp As API.XGIS_Point
dim p3x, p3y, p4x, p4y As double
dim radius as integer
dim tpl as New API.XGIS_TopologyClass
p1 = session("point_1")
p2 = session("point_2")
pll = GIS.API.Get("points")
if (Not p1 is Nothing) then
pshp = pll.CreateShape(API.XGIS_ShapeType.XgisShapeTypePoint)
pshp.Lock(API.XGIS_Lock.XgisLockExtent)
pshp.AddPart()
pshp.AddPoint(p1)
pshp.Unlock()
pshp = pll.AddShape(pshp)
pll.Params.Marker.Size=120
pll.Params.Marker.Color=System.Convert.ToUInt32(RGB(80,200,60))
pll.Params.Marker.OutlineColor=System.Convert.ToUInt32(RGB(80,60,200))
pll.Params.Marker.OutlineWidth=30
pll.Params.Marker.Style=API.XGIS_MarkerStyle.XgisMarkerStyleCircle
if (Not p1 is Nothing) and (Not p2 Is nothing) then
pshp.Lock(API.XGIS_Lock.XgisLockExtent)
pshp.AddPart()
pshp.AddPoint(p2)
pshp.Unlock()
pshp = pll.AddShape(pshp)
Select Case GIS_Options.SelectedItem.Value
Case 1
lshp = GIS.API.Get("buffers").CreateShape(API.XGIS_ShapeType.XgisShapeTypeArc )
lshp.Lock(2)
lshp.AddPart()
lshp.AddPoint( GisUtils.GisPoint( p1.X, p1.Y ) )
lshp.AddPoint( GisUtils.GisPoint( p2.X, p2.Y ) )
lshp.Unlock()
Lbl_Desc_1.Text = "States selected by line:"
Lbl_Desc_2.Visible = False
StatesList.Visible = True
Case 2
'create center point of circle
p3x = (p1.x + p2.x)/2
p3y = (p1.y + p2.y)/2
cp = GisUtils.GisPoint(p3x, p3y)
cshp = pll.CreateShape(API.XGIS_ShapeType.XgisShapeTypePoint)
cshp.Lock(API.XGIS_Lock.XgisLockExtent)
cshp.AddPart()
cshp.AddPoint(cp)
cshp.Unlock()
radius = Math.Round(Math.Sqrt(((p1.X - p2.x) * (p1.X - p2.x)) + ((p1.Y - p2.y) * (p1.Y - p2.y))))/2
shp = tpl.MakeBuffer(cshp, radius, 0, True)
cshp.Delete()
Lbl_Desc_1.Text = "States selected by circle:"
Lbl_Desc_2.Visible = False
StatesList.Visible = True
Case 3
p3x = p1.x
p3y = p2.y
p4x = p2.x
p4y = p1.y
shp = GIS.API.Get("buffers").CreateShape(API.XGIS_ShapeType.XgisShapeTypePolygon )
shp.Lock(2)
shp.AddPart()
shp.AddPoint( GisUtils.GisPoint( p1.X, p1.Y ) )
shp.AddPoint( GisUtils.GisPoint( p3x, p3y ) )
shp.AddPoint( GisUtils.GisPoint( p2.X, p2.Y ) )
shp.AddPoint( GisUtils.GisPoint( p4x, p4y ) )
shp.Unlock()
Lbl_Desc_1.Text = "States selected by rectangle:"
Lbl_Desc_2.Visible = False
StatesList.Visible = True
End select
if not pshp is nothing then
SelectStates(pshp)
end if
if not shp is nothing then
shp.Params.Area.Pattern=API.XBrushStyle.XbsClear
shp.Params.Area.Color=System.Convert.ToUInt32(RGB(80,60,200))
shp.Params.Area.OutlineColor=System.Convert.ToUInt32(RGB(80,60,200))
shp.Params.Area.OutlineWidth=-3
shp = GIS.API.Get("buffers").AddShape(shp)
SelectStates(shp)
end if
if not lshp is nothing then
lshp = GIS.API.Get("buffers").AddShape(lshp)
lshp.Params.Line.Width=-3
lshp.Params.Line.Color=System.Convert.ToUInt32(RGB(80,60,200))
SelectStates(lshp)
end if
end if
end if
End sub
Sub SelectStates(buf as API.XGIS_Shape)
dim tmp as API.XGIS_Shape
dim ll as API.XGIS_LayerVector
dim i as integer
ll = GIS.API.Get("states")
If ll Is Nothing Then
'GIS.CtlUpdate()
Exit Sub
End If
ll.DeselectAll()
'check all shapes
dim Table as System.Data.DataTable = New System.Data.DataTable()
dim dr as System.Data.DataRow
Table.Columns.Add("Sid", GetType(String))
Table.Columns.Add("Name", GetType(String))
tmp = ll.FindFirst(buf.Extent, "", buf, "T********", True)
i=1
While Not tmp Is Nothing
tmp = tmp.MakeEditable
dr = Table.NewRow()
dr(0) = cstr(i)
dr(1) = tmp.GetField("name")
Table.Rows.Add(dr)
'tmp.Params.Area.Color = Convert.ToUInt32(RGB(0, 200, 80))
'tmp.Params.Area.Pattern = API.XBrushStyle.XbsHorizontal
'tmp.Params.Labels.Field = "Name"
'tmp.Params.Labels.Color = System.Convert.ToUInt32(RGB(255, 255, 255))
'tmp.Params.Labels.FontColor = System.Convert.ToUInt32(RGB(80, 80, 80))
'tmp.Params.Labels.Position = API.XGIS_LabelPositions.XgisLabelPositionMiddleCenter
tmp.IsSelected=True
i = i + 1
tmp = ll.FindNext
End While
StatesList.DataSource = Table.DefaultView
StatesList.DataBind
End Sub
</script>
<html>
<head>
<title>TatukGIS IS Sample</title>
<link href="style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<a name="top">
<h1>Select by line, circle or rectangle
</h1>
<h2 class="comment"><a href="../../samplesAPI.htm">TatukGIS Internet Server Samples</a>
</h2>
<form runat="server">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td width="25%">
<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 width="60%">
<asp:RadioButtonList id="GIS_Options" runat="server" Width="160px" RepeatDirection="Horizontal" OnSelectedIndexChanged="GIS_Options_SelectedIndexChanged" AutoPostBack="True">
<asp:ListItem Value="1" Selected="True">Line</asp:ListItem>
<asp:ListItem Value="2">Circle</asp:ListItem>
<asp:ListItem Value="3">Rectangle</asp:ListItem>
</asp:RadioButtonList>
</td>
<td align="right" width="15%">
<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="3">
<ttkGIS:XGIS_VIEWERIS id="GIS" onclick="GIS_Click" runat="server" Width="360px" BorderWidth="1px" BorderColor="CornflowerBlue" OnLoad="GIS_Load" Height="280px" OnPaint="GIS_Paint"></ttkGIS:XGIS_VIEWERIS>
</td>
</tr>
</tbody>
</table>
<p>
<asp:Table id="Table_Desc" runat="server" Width="364px" BorderWidth="2px" BorderColor="Navy" BackColor="LightBlue" Visible="False">
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server" id="Lbl_Desc_1" font-bold="True"></asp:Label>
<br />
<asp:Label runat="server" id="Lbl_Desc_2"></asp:Label>
<asp:DataList id="StatesList" runat="server">
<ItemTemplate>
<asp:Label id="Sid" runat="server" text='<%# cstr(Container.DataItem("Sid")) %>' /> <asp:Label id="Name" runat="server" text='<%# Container.DataItem("name") %>' />
</ItemTemplate>
</asp:DataList>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</p>
</form>
</a>
</body>
</html>