Solve
/// <summary> /// Solves this instance. /// </summary> /// <returns>IFeatureClass.</returns> public IFeatureClass Solve() { log.WriteLog("Solving..."); IGPMessages gpMessages = new GPMessagesClass(); try { ConfigureSolverSettings(); m_NAContext.Solver.Solve(m_NAContext, gpMessages, null); return m_NAContext.NAClasses.get_ItemByName("SALines") as IFeatureClass; } catch (Exception e) { log.WriteLog("GP执行失败:" + e.Message); return null; } finally { ////记录GPMessages string sGPMessages = GetGPMessagesAsString(gpMessages); log.WriteLog("GP执行信息:" + sGPMessages); log.WriteLog("Solve完成!"); } } /// <summary> /// Prepare the solver /// </summary> private void ConfigureSolverSettings() { ConfigureSettingsSpecificToServiceAreaSolver(); ConfigureGenericSolverSettings(); UpdateContextAfterChangingSettings(); } /// <summary> /// Update settings that only apply to the Service Area /// </summary> private void ConfigureSettingsSpecificToServiceAreaSolver() { INAServiceAreaSolver naSASolver = m_NAContext.Solver as INAServiceAreaSolver; naSASolver.DefaultBreaks = ParseBreaks(""); naSASolver.MergeSimilarPolygonRanges = false; naSASolver.OutputPolygons = esriNAOutputPolygonType.esriNAOutputPolygonNone; naSASolver.OverlapLines = false; naSASolver.SplitLinesAtBreaks = true; naSASolver.TravelDirection = esriNATravelDirection.esriNATravelDirectionFromFacility; naSASolver.OutputLines = esriNAOutputLineType.esriNAOutputLineTrueShape; } /// <summary> /// Update settings that apply to all solvers /// </summary> private void ConfigureGenericSolverSettings() { INASolverSettings naSolverSettings = m_NAContext.Solver as INASolverSettings; naSolverSettings.ImpedanceAttributeName = "Time"; // set the oneway restriction, if necessary IStringArray restrictions = naSolverSettings.RestrictionAttributeNames; restrictions.RemoveAll(); naSolverSettings.RestrictionAttributeNames = restrictions; //naSolverSettings.RestrictUTurns = esriNetworkForwardStarBacktrack.esriNFSBNoBacktrack; } /// <summary> /// When the solver has been update, the context must be updated as well /// </summary> private void UpdateContextAfterChangingSettings() { IDatasetComponent datasetComponent = m_NAContext.NetworkDataset as IDatasetComponent; IDENetworkDataset deNetworkDataset = datasetComponent.DataElement as IDENetworkDataset; m_NAContext.Solver.UpdateContext(m_NAContext, deNetworkDataset, new GPMessagesClass()); } /// <summary> /// Prepare the text string for breaks /// </summary> /// <param name="p">The p.</param> /// <returns>IDoubleArray.</returns> private IDoubleArray ParseBreaks(string p) { String[] breaks = p.Split(' '); IDoubleArray pBrks = new DoubleArrayClass(); int firstIndex = breaks.GetLowerBound(); int lastIndex = breaks.GetUpperBound(); for (int splitIndex = firstIndex; splitIndex <= lastIndex; splitIndex++) { try { pBrks.Add(Convert.ToDouble(breaks[splitIndex])); } catch (FormatException) { log.WriteLog("Breaks are not properly formatted. Use only digits separated by spaces"); pBrks.RemoveAll(); return pBrks; } } return pBrks; } /// <summary> /// Gets the GP messages as string. /// </summary> /// <param name="gpMessages">The gp messages.</param> /// <returns>System.String.</returns> public string GetGPMessagesAsString(IGPMessages gpMessages) { // Gather Error/Warning/Informative Messages var messages = new StringBuilder(); if (gpMessages != null) { for (int i = ; i < gpMessages.Count; i++) { IGPMessage gpMessage = gpMessages.GetMessage(i); string message = gpMessage.Description; switch (gpMessages.GetMessage(i).Type) { case esriGPMessageType.esriGPMessageTypeError: messages.AppendLine("Error " + gpMessage.ErrorCode + ": " + message); break; case esriGPMessageType.esriGPMessageTypeWarning: messages.AppendLine("Warning: " + message); break; default: messages.AppendLine("Information: " + message); break; } } } return messages.ToString(); }
Solve的更多相关文章
- Solve VS2010 Error "Exceptions has been thrown by the target of an invocation"
Sometimes when you open a VS2010 project, an error window will pop up with the error message "E ...
- solve the problem of 'java web project cannot display verification code'
my java code of the function: package com.util; import java.awt.Color; import java.awt.Font; import ...
- HDU1086You can Solve a Geometry Problem too(判断线段相交)
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
- ACM: FZU 2102 Solve equation - 手速题
FZU 2102 Solve equation Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & ...
- ACM:HDU 2199 Can you solve this equation? 解题报告 -二分、三分
Can you solve this equation? Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Su ...
- hdu 1086 You can Solve a Geometry Problem too
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
- 数论 - 组合数学 + 素数分解 --- hdu 2284 : Solve the puzzle, Save the world!
Solve the puzzle, Save the world! Problem Description In the popular TV series Heroes, there is a ta ...
- hdu 2199 Can you solve this equation?(二分搜索)
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- 看ImplicitBackwardEulerSparse关于static solve的代码
当选择static solve的时候,求解的流程如下: 1.获得内力 2.qresidual = 外力-内力,qdelta = qresidual, qdelta的非约束元素赋给bufferConst ...
随机推荐
- SQL Server 2008 安装过程中遇到“性能计数器注册表配置单元一致性”检查失败 问题的解决方法
操作步骤: 1. 在 Microsoft Windows 2003 或 Windows XP 桌面上,依次单击"开始"."运行",然后在"打开&quo ...
- Oracle索引梳理系列(七)- Oracle唯一索引、普通索引及约束的关系
版权声明:本文发布于http://www.cnblogs.com/yumiko/,版权由Yumiko_sunny所有,欢迎转载.转载时,请在文章明显位置注明原文链接.若在未经作者同意的情况下,将本文内 ...
- 笔记整理之 Bulk Insert
之前2篇日志整理了BCP大致的用法,这次整理一下它的兄弟 Bulk Insert 的写法以及和bcp那边的结合的用法. 首先,Bulk Insert 语句要在连接了Sql Server 服务器之后才执 ...
- springMVC 配置CharacterEncodingFilter之后不起效果
最近开始自学springMVC框架,遇到中文乱码这一经典问题,记录下解决过程,以便后续忘记 web.xml 里过滤器配置如下: <?xml version="1.0" enc ...
- eclipse中去除build时总是js错误的问题
在用eclipse时经常莫名其名的弹出如下框框,有的时候甚至还死循环了.严重影响开发效率. 原因分析就是我们项目的一些js代码,eclipse验证时有错误的,其实是没有错误的.不知道eclipse是怎 ...
- Android应用源码基于安卓的个人隐私监控项目
本系统借鉴了现有安全软件的优点,设计了权限访问监控.流量监控.应用程序危险度监控和签名验证四个功能模块,同时针对现有安全软件的不足之处,对系统进行改进,让权限访问.流量监控.危险值等以图形化的方式呈现 ...
- Xamarin.Android VSTS 持续集成
这些天做了一个基于 VSTS 的 Xamarin.Android的持续集成,这里分享下 Build Agent 环境需求 DotNetFramework msbuild visualstudio An ...
- log4j.properties配置
一.日志:除了能记录异常信息,还可以记录程序正常运行时的关键信息. 使用log4j来进行日志文件记录经典步骤: 01.在项目中创建一个lib文件夹,然后将下载好的jar包copy到该文件夹下 02.对 ...
- 项目<<魔兽登录系统>>
创建魔兽系统相关窗体: 登录窗体(frmLogin) 注册窗体(frmRegister) 主窗体 (frmMain) 实现魔兽登录系统: 登录的界面如下 实现思路: 1.创建一个对象数组,长度为1 ...
- 嵌入式Linux驱动学习之路(二十一)字符设备驱动程序总结和块设备驱动程序的引入
字符设备驱动程序 应用程序是调用C库中的open read write等函数.而为了操作硬件,所以引入了驱动模块. 构建一个简单的驱动,有一下步骤. 1. 创建file_operations 2. 申 ...