【已测试通过】::ArcGISServer对点要素进行缓冲区分析
已测试通过::对点要素进行缓冲区分析效果图
以下是vb.net代码:(参考Flyingis C#代码http://flyingis.cnblogs.com/)
MapResourceManager设置如图
Protected Sub ButtonBuffer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonBuffer.Click
Dim pt As New ESRI.ArcGIS.ADF.ArcGISServer.PointN
pt.X = TextBoxX.Text
pt.Y = TextBoxY.Text
'设置点的颜色
Dim rgb As New ESRI.ArcGIS.ADF.ArcGISServer.RgbColor
rgb.Red = 0
rgb.Green = 20
rgb.Blue = 0
'设置点的符号
Dim sms As New ESRI.ArcGIS.ADF.ArcGISServer.SimpleMarkerSymbol
sms.Style = esriSimpleMarkerStyle.esriSMSCircle
sms.Color = rgb
sms.Size = 20
Dim marker As New ESRI.ArcGIS.ADF.ArcGISServer.MarkerElement
marker.Symbol = sms
marker.Point = pt
'建立ArcGIS Server Local方式到DataSource的连接(用户名,密码,计算机名)
Dim identity As New ESRI.ArcGIS.ADF.Identity("username", "pws", "hostname")
Dim agsconnection As New ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection("hostname", identity)
agsconnection.Connect()
If Not agsconnection.IsConnected = True Then
Throw New Exception("Administrator" + " Connected failed!")
End If
Dim som As ESRI.ArcGIS.Server.IServerObjectManager = agsconnection.ServerObjectManager
Dim serverContext As ESRI.ArcGIS.Server.IServerContext = som.CreateServerContext("ServerTest", "MapServer")
'定义COM对象的点
Dim ipnt As ESRI.ArcGIS.Geometry.IPoint
'进行valueobject到comobject之间的转换
ipnt = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ValueObjectToComObject(pt, serverContext)
'下面是AO中缓冲区分析的代码
Dim topop As ESRI.ArcGIS.Geometry.ITopologicalOperator = ipnt
Dim bufferdistance As Double = Map1.Extent.Width / 6
Dim bufferpolygon As ESRI.ArcGIS.Geometry.IPolygon = topop.Buffer(bufferdistance)
'bufferPolygon就是缓冲区分析的结果,但它还不是我们最后想要的,因为ESRI.ArcGIS.Geometry.IPolygon无法在adf web control中显示,还需要做一次转换:
'定义valueobject的点
Dim buffer_polyn As ESRI.ArcGIS.ADF.ArcGISServer.PolygonN = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ComObjectToValueObject(bufferpolygon, serverContext, GetType(ESRI.ArcGIS.ADF.ArcGISServer.PolygonN))
'buffer_polyn就是我们最后想要的结果,定义一种渲染方式:
Dim rgb1 As New ESRI.ArcGIS.ADF.ArcGISServer.RgbColor
rgb1.Red = 200
rgb1.Green = 200
rgb1.Blue = 20
'设置区的填充色
Dim sfs1 As New ESRI.ArcGIS.ADF.ArcGISServer.SimpleFillSymbol
sfs1.Style = esriSimpleFillStyle.esriSFSHorizontal
sfs1.Color = rgb1
Dim polyelement1 As New ESRI.ArcGIS.ADF.ArcGISServer.PolygonElement
polyelement1.Symbol = sfs1
polyelement1.Polygon = buffer_polyn
'最后将marker和polyelement1添加到ESRI.ArcGIS.ADF.ArcGISServer.GraphicElement对象数组中,传给当前MapFunctionality的CustomGraphics属性,刷新map控
Dim ges(2) As ESRI.ArcGIS.ADF.ArcGISServer.GraphicElement
ges(0) = marker
ges(1) = polyelement1
Dim mapfun As ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality = Map1.GetFunctionality(0)
Dim mapdes As ESRI.ArcGIS.ADF.ArcGISServer.MapDescription = mapfun.MapDescription
mapdes.CustomGraphics = ges
End Sub
以下是vb.net代码:(参考Flyingis C#代码http://flyingis.cnblogs.com/)
MapResourceManager设置如图
Protected Sub ButtonBuffer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonBuffer.Click
Dim pt As New ESRI.ArcGIS.ADF.ArcGISServer.PointN
pt.X = TextBoxX.Text
pt.Y = TextBoxY.Text
'设置点的颜色
Dim rgb As New ESRI.ArcGIS.ADF.ArcGISServer.RgbColor
rgb.Red = 0
rgb.Green = 20
rgb.Blue = 0
'设置点的符号
Dim sms As New ESRI.ArcGIS.ADF.ArcGISServer.SimpleMarkerSymbol
sms.Style = esriSimpleMarkerStyle.esriSMSCircle
sms.Color = rgb
sms.Size = 20
Dim marker As New ESRI.ArcGIS.ADF.ArcGISServer.MarkerElement
marker.Symbol = sms
marker.Point = pt
'建立ArcGIS Server Local方式到DataSource的连接(用户名,密码,计算机名)
Dim identity As New ESRI.ArcGIS.ADF.Identity("username", "pws", "hostname")
Dim agsconnection As New ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection("hostname", identity)
agsconnection.Connect()
If Not agsconnection.IsConnected = True Then
Throw New Exception("Administrator" + " Connected failed!")
End If
Dim som As ESRI.ArcGIS.Server.IServerObjectManager = agsconnection.ServerObjectManager
Dim serverContext As ESRI.ArcGIS.Server.IServerContext = som.CreateServerContext("ServerTest", "MapServer")
'定义COM对象的点
Dim ipnt As ESRI.ArcGIS.Geometry.IPoint
'进行valueobject到comobject之间的转换
ipnt = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ValueObjectToComObject(pt, serverContext)
'下面是AO中缓冲区分析的代码
Dim topop As ESRI.ArcGIS.Geometry.ITopologicalOperator = ipnt
Dim bufferdistance As Double = Map1.Extent.Width / 6
Dim bufferpolygon As ESRI.ArcGIS.Geometry.IPolygon = topop.Buffer(bufferdistance)
'bufferPolygon就是缓冲区分析的结果,但它还不是我们最后想要的,因为ESRI.ArcGIS.Geometry.IPolygon无法在adf web control中显示,还需要做一次转换:
'定义valueobject的点
Dim buffer_polyn As ESRI.ArcGIS.ADF.ArcGISServer.PolygonN = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ComObjectToValueObject(bufferpolygon, serverContext, GetType(ESRI.ArcGIS.ADF.ArcGISServer.PolygonN))
'buffer_polyn就是我们最后想要的结果,定义一种渲染方式:
Dim rgb1 As New ESRI.ArcGIS.ADF.ArcGISServer.RgbColor
rgb1.Red = 200
rgb1.Green = 200
rgb1.Blue = 20
'设置区的填充色
Dim sfs1 As New ESRI.ArcGIS.ADF.ArcGISServer.SimpleFillSymbol
sfs1.Style = esriSimpleFillStyle.esriSFSHorizontal
sfs1.Color = rgb1
Dim polyelement1 As New ESRI.ArcGIS.ADF.ArcGISServer.PolygonElement
polyelement1.Symbol = sfs1
polyelement1.Polygon = buffer_polyn
'最后将marker和polyelement1添加到ESRI.ArcGIS.ADF.ArcGISServer.GraphicElement对象数组中,传给当前MapFunctionality的CustomGraphics属性,刷新map控
Dim ges(2) As ESRI.ArcGIS.ADF.ArcGISServer.GraphicElement
ges(0) = marker
ges(1) = polyelement1
Dim mapfun As ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality = Map1.GetFunctionality(0)
Dim mapdes As ESRI.ArcGIS.ADF.ArcGISServer.MapDescription = mapfun.MapDescription
mapdes.CustomGraphics = ges
End Sub