




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、ArcGIS Server 9.3 最短路徑分析要做網(wǎng)絡(luò)分析,首先你的arcgis server需要具有network analysis 擴(kuò)展模塊的license。其次需要網(wǎng)絡(luò)數(shù)據(jù)集,這個(gè)問題好解決,直接使用安裝目錄下的ArcGIS"DeveloperKit"SamplesNET"Server"data"SanFrancisco下的網(wǎng)絡(luò)數(shù)據(jù)集將其發(fā)布,發(fā)布時(shí)記得勾上NetWork Anaysis 這項(xiàng)。然后新建一個(gè)網(wǎng)站,加上常用的map,mapresourcemanager,toolbar,toc 控件等,在mapresourcemanager
2、中加入兩個(gè)資源,一個(gè)是graphicslayer類型,命名為 pathLayer,一個(gè)為ArcGIS Server Local類型,命名為SanFrancisco,并加上兩個(gè)textbox和一個(gè)按鈕,布置好后如圖1。首先在前臺(tái)的代碼如下:/函數(shù)search()即為所加按鈕的onclick對應(yīng)的函數(shù)。<script type="text/javascript"> function search()
3、 /起點(diǎn)的名稱 var v1=document.getElementById("Text1").value; /終點(diǎn)的名稱 var v2=document.getElementById("Text2").value; var argum
4、ent = "ControlID=Map1&ControlType=Map&Type=findPath&p1="+v1+"&p2="+v2; var context = "Map" <%= m_Callback %> &
5、#160; function processCallbackError() alert(66); </script> 后臺(tái)還是callback機(jī)制來實(shí)現(xiàn)的。代碼如下:public partial class _Default : System.Web.UI.Page,ICallbackEventHandler public string m_C
6、allback = String.Empty; public string smapstring = String.Empty; protected void Page_Load(object sender, EventArgs e) if (!IsPostBack) m_
7、Callback = Page.ClientScript.GetCallbackEventReference(Page, "argument", "processCallbackResult", "context", "processCallbackError", true); #region ICallbackEventHandler 成員 public string GetCallbackResult() &
8、#160; return smapstring; public void RaiseCallbackEvent(string eventArgument) /請求字符串 NameValueCollection keyValColl = CallbackUtility.ParseStringIntoN
9、ameValueCollection(eventArgument); if (keyValColl"Type".ToString() = "findPath") System.Text.StringBuilder sb = new System.Text.S
10、tringBuilder(); /起點(diǎn)名稱 string Input1 = keyValColl"p1" /終點(diǎn)名稱
11、0; string Input2 = keyValColl"p2" /路徑分析 doFindPath(Input1, Input2);
12、 #endregion /查詢最短路徑的主體函數(shù) private void doFindPath(string name1, string name2) /ags的服務(wù)器名 string SERVER_NAME = "ZHOUWEN" /ags
13、里發(fā)布的Map Service名 string ROUTE_SERVICE_NAME = "SanFrancisco" /創(chuàng)建NAServerProxy NAServerProxy naServerProxy = NAServerProxy.Create(SERVER_NAME, ROUTE_SERVICE_NAME, nul
14、l); if (naServerProxy = null) naServerProxy.Dispose(); throw (new System.Exception(
15、"Error"); else /獲取網(wǎng)絡(luò)層的名稱 string nLayers = naServ
16、erProxy.GetNALayerNames(esriNAServerLayerType.esriNAServerRouteLayer); NAServerSolverParams solverParams = naServerProxy.GetSolverParameters(nLayers0) as NAServerSolve
17、rParams; /路由分析參數(shù) NAServerRouteParams routeParams = solverParams as NAServerRouteParams; /不返回地圖
18、160; routeParams.ReturnMap = false; /返回RouteGeometries routeParams.ReturnRouteGeometries = true;
19、 routeParams.ReturnStops = true; routeParams.ReturnDirections = true; /設(shè)置起點(diǎn)PropertySet參數(shù)
20、160; PointN point = QueryPoint(name1); PropertySet propSet = new PropertySet(); PropertySetProperty propSetProperty_new = new Proper
21、tySetProperty2; propSet.PropertyArray = propSetProperty_new; PropertySetProperty propSetProperty = new PropertySetProperty(); &
22、#160; propSetProperty.Key = "Shape" propSetProperty.Value = point; PropertySetProperty propSetProperty2 = new PropertySetPropert
23、y(); propSetProperty2.Key = "Name" propSetProperty2.Value = name1; propSet.PropertyArr
24、ay0 = propSetProperty; propSet.PropertyArray1 = propSetProperty2; /設(shè)置終點(diǎn)PropertySet參數(shù) PointN poin
25、t2 = QueryPoint(name2); PropertySet propSet2 = new PropertySet(); PropertySetProperty propSetProperty_new2 = new PropertySetProperty2;
26、0; propSet2.PropertyArray = propSetProperty_new2; PropertySetProperty propSetProperty3 = new PropertySetProperty(); propSetProperty3
27、.Key = "Shape" propSetProperty3.Value = point2; PropertySetProperty propSetProperty4 = new PropertySetProperty();
28、60; propSetProperty4.Key = "Name" propSetProperty4.Value = name2; propSet2.PropertyArray0 = propSetProperty3; &
29、#160; propSet2.PropertyArray1 = propSetProperty4; /設(shè)置Stops參數(shù) PropertySet propSets = new PropertySet2; &
30、#160; propSets0 = propSet; propSets1 = propSet2; NAServerPropertySets StopsPropSets = new NAServerPropertySets(); &
31、#160; StopsPropSets.PropertySets = propSets; routeParams.Stops = StopsPropSets; NAServerSolverResults solverResults;
32、0; try /進(jìn)行分析
33、; solverResults = naServerProxy.Solve(solverParams); NAServerRouteResults RouteSolverResults = solverResults as NAServerRouteResults;
34、; /顯示分析結(jié)果 ShowResults(solverResults); /釋放naServerProxy
35、 naServerProxy.Dispose(); catch (Exception e) &
36、#160; /釋放naServerProxy naServerProxy.Dispose();
37、 smapstring = Map1.CallbackResults.ToString(); /在地圖上展示最短路徑 public void ShowResults(NAServerSolverResults solverResults)
38、; NAServerRouteResults RouteSolverResults = solverResults as NAServerRouteResults; /開始點(diǎn)終點(diǎn)路徑顯示 AddRoutesAndStops(RouteSolverResults); /路徑區(qū)域全屏顯示
39、160; PolylineN polylineN = RouteSolverResults.RouteGeometries0 as PolylineN; EnvelopeN envelopeN = polylineN.Extent as EnvelopeN; double width = envelopeN.XMax - envelopeN.XMin;
40、160; double height = envelopeN.YMax - envelopeN.YMin; double fivePercent; if (width > height) fiveP
41、ercent = width * .05; else fivePercent = height * .05;
42、60; envelopeN.XMin = envelopeN.XMin - fivePercent; envelopeN.YMin = envelopeN.YMin - fivePercent; envelopeN.XMax = envelopeN.XMax + fivePercent;
43、 envelopeN.YMax = envelopeN.YMax + fivePercent; Map1.Extent = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToAdfEnvelope(envelopeN); Map1.Refresh(); private void AddRoutesAndStops(NAServer
44、RouteResults rResult) /分析結(jié)果路徑 Polyline lines = rResult.RouteGeometries; RecordSet stops = rResult.Stops; /獲取Buffe
45、r的MapFunctionality ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality mapFunct = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapFunctionality)Map1.GetFunctionality("pathLayer"); /獲取Buffer的MapResource
46、160; ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource gResource = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)mapFunct.Resource; /把buffer結(jié)果范圍進(jìn)行顯示 ESRI.ArcGIS.ADF.Web.
47、Display.Graphics.ElementGraphicsLayer glayer = null; /查找ElementGraphicsLayer在Buffer中 foreach (System.Data.DataTable dt in gResource.Graphics.Tables) &
48、#160; if (dt is ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer) glayer = (ESRI.ArcGIS.ADF.Web.Di
49、splay.Graphics.ElementGraphicsLayer)dt; break; /如果Buffer中沒
50、有ElementGraphicsLayer就新增加一個(gè)ElementGraphicsLayer if (glayer = null) glayer = new ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer();
51、60; gResource.Graphics.Tables.Add(glayer); /清除ElementGraphicsLayer中的內(nèi)容 glayer.Clear();
52、60; ESRI.ArcGIS.ADF.Web.Geometry.Geometry geom = (ESRI.ArcGIS.ADF.Web.Geometry.Geometry)ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToAdfPolyline(PolylineN)lines0); /設(shè)置點(diǎn)顯示 ESRI.ArcGIS.ADF.Web.Display
53、.Graphics.GraphicElement ge = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(geom, System.Drawing.Color.Red); /設(shè)置透明度 ESRI.ArcGIS.ADF.Web.Display.Symbol.SimpleLineSymbol sls = new ESRI.ArcGIS.ADF.Web.Display.
54、Symbol.SimpleLineSymbol(); sls.Width = 5; sls.Color = System.Drawing.Color.Blue; sls.Type = ESRI.ArcGIS.ADF.Web.Display.Symbol.LineType.Dash;
55、60; sls.Transparency = 50; ge.Symbol = sls; / ge.Symbol.Transparency = 50; /添加到Buffer中進(jìn)行顯示 glayer.Add(ge);
56、160; Record stopRecords = stops.Records; int stopCount = stopRecords.Length; for (int iStop = 0; iStop < stopCount; iStop+)
57、; ESRI.ArcGIS.ADF.Web.Geometry.Geometry geom2 = (ESRI.ArcGIS.ADF.Web.Geometry.Geometry)ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToAdfPoint(stopRecordsiStop.Values1 as PointN); /設(shè)置點(diǎn)顯示
58、160; ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement ge2 = new ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(geom2, System.Drawing.Color.Red); /設(shè)置透明度
59、60; ge2.Symbol.Transparency = 50; /添加到Buffer中進(jìn)行顯示 glayer.Add(ge2);
60、; /按名稱查找點(diǎn) private PointN QueryPoint(string name) PointN point = new PointN(); IEnumerable func_enum = Map1.GetFunctionalities();
61、160; DataTable dt = null; foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality gisfunctionality in func_enum) if (gisfunctionality.
62、Resource.Name = "SanFrancisco") bool supported = false;
63、 ESRI.ArcGIS.ADF.Web.DataSources.IGISResource gisresource = gisfunctionality.Resource; supported = gisresource.SupportsFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality);
64、; if (supported) &
65、#160; ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality qfunc = (ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)gisresource.CreateFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), null);
66、0; string lids; string lnames; qfunc.GetQu
67、eryableLayers(null, out lids, out lnames); ESRI.ArcGIS.ADF.Web.SpatialFilter spatialfilter = new ESRI.ArcGIS.ADF.Web.SpatialFilter();
68、; spatialfilter.ReturnADFGeometries = false; spatialfilter.MaxRecords = 1;
69、0; spatialfilter.WhereClause = "NAME LIKE '" + name + "'" spatialfilter.Geometry = Map1.GetF
70、ullExtent(); dt = qfunc.Query(null, lids3, spatialfilter); /lnames名稱
71、0; /0: "Stops" /1: "Barriers" /2:
72、"Routes" /3: "Facilities" /4: "Incidents" &
73、#160; /5: "Barriers" /6: "Routes" /7: "Facilities"
74、0; /8: "Barriers" /9: "Lines"
75、; /10: "Polygons" /11: "Hospital" /12: "bayareamultiroutestops"
76、60; /13: "bayareaincident" /14: "bayareafacilities" /15: "HwySt"
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 樂理題庫及答案資源
- 基于注意力機(jī)制的圖像分類-洞察闡釋
- 環(huán)境友好材料在土木工程中的運(yùn)用
- 知名餐飲品牌連鎖入股合作專項(xiàng)協(xié)議
- 文化展覽館場地?zé)o償使用及展覽策劃服務(wù)合同
- 展覽館場地租用合同樣本
- 互聯(lián)網(wǎng)工業(yè)廠房物業(yè)委托管理與電商服務(wù)合同
- 2025【合同范本】互聯(lián)網(wǎng)服務(wù)費(fèi)用同城特約委托收款協(xié)議書
- 2025汽車銷售合同樣本版
- 2025合同范本有限合伙企業(yè)隱名合伙人協(xié)議示例
- 環(huán)水??荚囋囶}及答案
- 成人機(jī)械通氣患者俯臥位護(hù)理課件
- 四川省內(nèi)江市市中區(qū)2025年小數(shù)畢業(yè)模擬試卷(含答案)
- 管理學(xué)原理第十章控制
- 《中國傳統(tǒng)節(jié)慶文化》課件
- 2025佛山市順德區(qū)輔警考試試卷真題
- 學(xué)歷提升合同協(xié)議書范本
- 2025年鄭州鐵路職業(yè)技術(shù)學(xué)院單招職業(yè)傾向性測試題庫必考題
- 2025-2030中國袋式除塵器市場需求前景與發(fā)展動(dòng)向追蹤研究報(bào)告
- 對標(biāo)一流-2025年國央企風(fēng)控合規(guī)案例白皮書-啟信慧眼
- GB/T 19598-2025地理標(biāo)志產(chǎn)品質(zhì)量要求安溪鐵觀音
評(píng)論
0/150
提交評(píng)論