博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
创建ServiceArea
阅读量:6202 次
发布时间:2019-06-21

本文共 4288 字,大约阅读时间需要 14 分钟。

///         /// Services the area.        ///         /// The network dataset.        public void ServiceArea(INetworkDataset networkDataset)        {            log.WriteLog("开始创建ServiceArea...");             IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass();            IWorkspace workspace = workspaceFactory.OpenFromFile(Functions.g_WorkSpacePath, 0);            IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;                       CreateSolverContext(networkDataset);            if (!LoadLocations(featureWorkspace, Functions.g_Hospital))            {                log.WriteLog("LoadLocations失败!");            }             log.WriteLog("ServiceArea创建完成!");        } ///         /// Geodatabase function: get network dataset        ///         /// Input network dataset        /// 
DE network dataset
public IDENetworkDataset GetDENetworkDataset(INetworkDataset networkDataset) { // Cast from the network dataset to the DatasetComponent IDatasetComponent dsComponent = networkDataset as IDatasetComponent; // Get the data element return dsComponent.DataElement as IDENetworkDataset; } /// /// Create NASolver and NAContext /// /// Input network dataset private void CreateSolverContext(INetworkDataset networkDataset) { if (networkDataset == null) return; //Get the Data Element IDENetworkDataset deNDS = GetDENetworkDataset(networkDataset); INASolver naSolver = new NAServiceAreaSolverClass(); m_NAContext = naSolver.CreateContext(deNDS, naSolver.Name); ((INAContextEdit)m_NAContext).Bind(networkDataset, new GPMessagesClass()); } /// /// Loads the locations. /// /// The feature workspace. /// The input facilities. ///
true
if XXXX,
false
otherwise
private bool LoadLocations(IFeatureWorkspace featureWorkspace, string inputFacilities) { IFeatureClass inputFeatureClass = null; try { inputFeatureClass = featureWorkspace.OpenFeatureClass(inputFacilities); } catch (Exception) { log.WriteLog("Specified input feature class does not exist"); return false; } INamedSet classes = m_NAContext.NAClasses; INAClass naClass = classes.get_ItemByName("Facilities") as INAClass; // delete existing locations, except barriers naClass.DeleteAllRows(); // Create a NAClassLoader and set the snap tolerance (meters unit) INAClassLoader naClassLoader = new NAClassLoaderClass(); naClassLoader.Locator = m_NAContext.Locator; ((INALocator3)naClassLoader.Locator).MaxSnapTolerance = 500; naClassLoader.NAClass = naClass; // Create field map to automatically map fields from input class to NAClass INAClassFieldMap naClassFieldMap = new NAClassFieldMapClass(); naClassFieldMap.CreateMapping(naClass.ClassDefinition, inputFeatureClass.Fields); naClassLoader.FieldMap = naClassFieldMap; // Avoid loading network locations onto non-traversable portions of elements INALocator3 locator = m_NAContext.Locator as INALocator3; locator.ExcludeRestrictedElements = true; locator.CacheRestrictedElements(m_NAContext); // load network locations int rowsIn = 0; int rowsLocated = 0; IQueryFilter qf = new QueryFilterClass(); qf.WhereClause = "aaaaaaaaaaa"; naClassLoader.Load(inputFeatureClass.Search(qf, true) as ICursor, null, ref rowsIn, ref rowsLocated); if (rowsLocated <= 0) { log.WriteLog("Facilities were not loaded from input feature class"); return false; } // Message all of the network analysis agents that the analysis context has changed INAContextEdit naContextEdit = m_NAContext as INAContextEdit; naContextEdit.ContextChanged(); return true; }

 

转载地址:http://gqtca.baihongyu.com/

你可能感兴趣的文章
VC6.0之Debug调试总结
查看>>
Android应用程序消息处理机制(Looper、Handler)分析(4)
查看>>
C++ 类成员的构造和析构顺序
查看>>
将String转化成Stream,将Stream转换成String
查看>>
java路径Java开发中获得非Web项目的当前项目路径
查看>>
Google API设计指南-资源名称
查看>>
最全React技术栈技术资料汇总(收藏)
查看>>
bat文件的一些小技巧
查看>>
【工具使用系列】关于 MATLAB 遗传算法与直接搜索工具箱,你需要知道的事
查看>>
flex 学习笔记 stage
查看>>
Kali-linux Arpspoof工具
查看>>
java中三个类别加载器的关系以及各自加载的类的范围
查看>>
PDF文档页面如何重新排版?
查看>>
基于http协议使用protobuf进行前后端交互
查看>>
python3 + Django + uwsgi + nginx 配置部署笔记
查看>>
UML设计一个电影票务销售系统(四)
查看>>
如何给VEEAM 7 分配角色权限
查看>>
AlphaGo Zero用它来调参?【高斯过程】到底有何过人之处?
查看>>
《Redis官方教程》Redis集群规范(二)
查看>>
MacOS必备软件
查看>>