(物流管理)AGIS S 开发系列(七)物流配送

上传人:管****问 文档编号:119650335 上传时间:2020-01-21 格式:DOC 页数:9 大小:249.93KB
返回 下载 相关 举报
(物流管理)AGIS S 开发系列(七)物流配送_第1页
第1页 / 共9页
(物流管理)AGIS S 开发系列(七)物流配送_第2页
第2页 / 共9页
(物流管理)AGIS S 开发系列(七)物流配送_第3页
第3页 / 共9页
(物流管理)AGIS S 开发系列(七)物流配送_第4页
第4页 / 共9页
(物流管理)AGIS S 开发系列(七)物流配送_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《(物流管理)AGIS S 开发系列(七)物流配送》由会员分享,可在线阅读,更多相关《(物流管理)AGIS S 开发系列(七)物流配送(9页珍藏版)》请在金锄头文库上搜索。

1、ArcGIS Server 开发系列(七)-物流配送2008-12-31 15:58 by Flyingis, 5230 visits, 作者:Flyingis ArcGIS Server开发系列的文章至今已经一年多了,虽然文章只有短短六篇,也比较基础,但值得高兴的是帮助了不少第一次接触ArcGIS Server的开发者,现在不少都已经完成一两个项目了,相信收获不小,有时间可以和大家一起分享经验。今天开始,我们将继续这个系列教程,争取覆盖ADF开发常用功能,以帮助更多的人轻松入门ADF开发。 目标: 实现简易的物流配送(VRP) 准备工作: 1.重新复习ArcGIS Server 开发系列(六

2、)-自定义 Tasks 2.准备数据%ArcGISInstallDir%DeveloperKitSamplesNETServerdataSanFranciscoNetwork 3.发布NATasks.mxd地图服务,添加Network Analyst功能服务 4.MapResourceManager中添加一个ArcGIS Server Local类型服务 在这个应用中,多车配送的功能封装为一个自定义的Task,然后生成一个dll添加到ASP.Net工具箱中,由Web Mapping Application的Task Manager调用,更改自定义Task的Task Results Contai

3、ner为模板应用中的TaskResults1控件。 Web Mapping Application大家已经非常熟悉,现在的重点就在如何利用ArcGIS Server实现VRP功能。VRP全称vehicle routing problem,属于NP难问题,基本没有统一的方法来解决所有的VRP问题,只能根据具体的情况采用最合适的算法,咱们下面就利用ArcGIS Server模拟一个简单的应用场景,实现多车物流的配送计算。 自定义Task,需要构建Task的UI和业务逻辑,UI构建通过重写方法CreateChildControls完成,咱们最终实现的效果:相应的代码比较容易看懂,结合上面实现的UI效

4、果图和代码注释就能明白每部分代码所完成的功能,实现代码:protectedoverridevoidCreateChildControls()Controls.Clear();base.CreateChildControls();Createtopleveltable#regionCreatetopleveltableSystem.Web.UI.WebControls.Tabletable=newSystem.Web.UI.WebControls.Table();table.Width=System.Web.UI.WebControls.Unit.Pixel(240);Controls.Add(

5、table);TableRowtr;TableCelltd;#endregionOrdersLabel#regionOrdersLabeltr=newTableRow();td=newTableCell();td.Text=Selectorderstoservice;tr.Cells.Add(td);table.Rows.Add(tr);#endregionCreateandpopulateordersListbox#regionCreateandpopulateordersListbox_oids=newList();_ordersCheckBoxList=newCheckBoxList()

6、;_ordersCheckBoxList.ID=OrdersCheckBoxList;_ordersCheckBoxList.Width=System.Web.UI.WebControls.Unit.Point(200);IServerContextserverContext=MapResourceLocal.ServerContextInfo.ServerContext;IMapvrpMap=Utility.GetCartoIMap(MapInstance,NA_MapResourceItem);IFeatureLayerordersInputFLayer=Utility.GetFeatur

7、eLayer(Stores,vrpMap);IFeatureClassordersInputFClass=ordersInputFLayer.FeatureClass;intnameIndex=ordersInputFClass.FindField(Name);IFeatureCursorordersInputFCursor=ordersInputFClass.Search(null,false);IFeatureorderFeature=ordersInputFCursor.NextFeature();while(orderFeature!=null)ListItemli=newListIt

8、em(orderFeature.get_Value(nameIndex).ToString();li.Selected=true;_ordersCheckBoxList.Items.Add(li);_oids.Add(orderFeature.OID);orderFeature=ordersInputFCursor.NextFeature();#endregionOrdersPanel#regionOrdersPaneltr=newTableRow();td=newTableCell();PanelordersPanel=newPanel();ordersPanel.Height=200;or

9、dersPanel.Width=240;ordersPanel.BorderColor=System.Drawing.Color.Black;ordersPanel.BorderStyle=BorderStyle.Inset;ordersPanel.BorderWidth=1;ordersPanel.ScrollBars=ScrollBars.Vertical;ordersPanel.Controls.Add(_ordersCheckBoxList);td.Controls.Add(ordersPanel);tr.Cells.Add(td);table.Rows.Add(tr);#endreg

10、ionGetDirectionsButton#regionGetDirectionsButtontr=newTableRow();tr.Attributes.Add(align,right);td=newTableCell();td.ColumnSpan=2;HtmlInputButtonbutton=newHtmlInputButton();button.Value=GetDirections;button.ID=execute;td.Controls.Add(button);tr.Cells.Add(td);table.Rows.Add(tr);#endregionOnClickEvent

11、forexecutingtask#regionOnClickEventforexecutingtaskstringargument=string.Format(selectedIndexes=+getCheckedItemIndexes(0,1),_ordersCheckBoxList.ClientID,_ordersCheckBoxList.Items.Count);stringonClick=string.Format(executeTask(0,1);,argument,CallbackFunctionString);button.Attributes.Add(onclick,onCli

12、ck);#endregion/AccessthegraphicslayersoitiscreatedandshownintheTOCElementGraphicsLayerpointsGraphicsLayer=PointsGraphicsLayer; CreateChildControls用于构建VRPTask UI,除了界面要素之外,还需要从源数据中读取商店信息,如读取商店名称显示在界面上,当VRPTask中的商店被勾选上时,车辆将为该商店送货。商店供货信息存储在数据源中单独的一个图层中stores.shp,包含商店所需的货物数量和预计提供服务的时间。 VRPTask UI完成之后,接下来

13、要设计VRP的业务逻辑,ArcGIS 9.3 Network Extension提供了一个基本的VRP解决方案,因此我们在发布NATasks服务的时候需要勾选Network Analyst功能,通过ServerContext去远程调用AO方法。 第一步,获取VRP分析图层。IServerContextserverContext=MapResourceLocal.ServerContextInfo.ServerContext;IMapvrpMap=Utility.GetCartoIMap(MapInstance,NA_MapResourceItem);IGPMessagesgpMessages=

14、serverContext.CreateObject(esriGeodatabase.GPMessages)asIGPMessages;INALayer2vrpNALayer=Utility.GetNALayer(VehicleRoutingProblem,vrpMap);INAContextvrpNAContext=vrpNALayer.CopyContext();INAContextEditvrpNAContextEdit=vrpNAContextasINAContextEdit;vrpNAContextEdit.Bind(vrpNALayer.Context.NetworkDataset,gpMessages); 第二步,获取配送中心信息、商店信息、车辆信息和司机午餐时间。IFeatureLayerdepotsInputFLayer=Utility.GetFeatureLayer(DistributionCenters,vrpMap);IFeatureClassdepotsInputFClass=de

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 经营企划

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号