创建路径(c#)-动态分段

简介: public void CreateRoutesUsing2Fields(string sAccessWS, string sLineFC, string sOutRouteFC, string sWhereClause, string sRouteIDField, string sFromMeas...
public void CreateRoutesUsing2Fields(string sAccessWS, string sLineFC, string sOutRouteFC, string sWhereClause, string sRouteIDField, string sFromMeasureField, string sToMeasureField)
        {
            try
            {
                //  VARIABLES
                //  sAccessWS - access workspace (i.e. "http://www.cnblogs.com/zuiyirenjian/admin/file://burt/data/dyndata/pitt.mdb")
                //  sLineFC - the input line feature class ("base_roads")
                //  sOutRouteFC - the output route feature class name ("routes")
                //  sWhereClause - query filter for line feature class if needed (i.e. "[RKey] <> 0")
                //  sRouteIDField - route ID field (i.e "Rkey")
                //  sFromMeasureField - the from-measure field (i.e. "BegMP")
                //  sToMeasureField - the to-measure field (i.e "EndMP")
 
                //Get the line feature class
                IWorkspaceFactory wsf = new AccessWorkspaceFactoryClass();
                IWorkspace ws = wsf.OpenFromFile(sAccessWS, 0);
                IFeatureWorkspace fws = (IFeatureWorkspace)ws;
                IFeatureClass lineFC = fws.OpenFeatureClass(sLineFC);
 
                // Create an output feature class name object. We'll write to a stand alone feature class in the
                // the same workspace as the inputs
                IDataset ds = (IDataset)ws;
                IWorkspaceName outWSN = (IWorkspaceName)ds.FullName;
                IFeatureClassName outFCN = new FeatureClassNameClass();
                IDatasetName outDSN = (IDatasetName)outFCN;
                outDSN.WorkspaceName = outWSN;
                outDSN.Name = sOutRouteFC; //This name should not already exist
 
                // Create a geometry definition for the new feature class. For the most part, we will copy the geometry
                // definition from the input lines. We'll explicitly set the M Domain, however. You should always set an
                // M Domain that is appropriate to your data. What is below is just a sample.
                IFields flds = lineFC.Fields;
                Int32 i = flds.FindField(lineFC.ShapeFieldName);
                IField fld = flds.get_Field(i);
                IClone GDefclone = (IClone)fld.GeometryDef;
                IGeometryDef gDef = (IGeometryDef)GDefclone.Clone();
                ISpatialReference2 srRef = (ISpatialReference2)gDef.SpatialReference;
                srRef.SetMFalseOriginAndUnits(-1000, 10000);

                // Create a selection set to limit the number of lines that will be used to create routes
                IQueryFilter qFilt = new QueryFilterClass();
                qFilt.WhereClause = sWhereClause;
                ISelectionSet2 selSet = (ISelectionSet2)lineFC.Select(qFilt, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, ws);
 
                // Create a new RouteMeasureCreator object. Note that below, we use the selection set and not the
                // InputFeatureClass property
                IRouteMeasureCreator routeCreator = new RouteMeasureCreatorClass();
                routeCreator.InputFeatureSelection = selSet;
                routeCreator.InputRouteIDFieldName = sRouteIDField;
                IEnumBSTR errors = routeCreator.CreateUsing2Fields(sFromMeasureField, sToMeasureField, outFCN, gDef, "", null);
 
                // The results of running CreatingUsing2Fields returns IEnumBSTR, which is a container
                // for a list of error strings indicating why certain lines could not be used to create routes.
                string sError = errors.Next();
                do
                {
                    System.Windows.Forms.MessageBox.Show(sError);
                    sError = errors.Next();
                } while (sError.Length != 0);
            }
            catch(Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
            }

相关文章
|
3天前
|
Windows
修改SubVI的LabVIEW默认搜索路径
修改SubVI的LabVIEW默认搜索路径
|
2月前
|
Windows
(文件[夹]批量分类整理_多级匹配_交叉匹配_路径结构交叉调整)文件[夹]批量复制
该文介绍了如何使用特定工具进行批量文件整理。首先,需要从提供的百度网盘和蓝奏云链接下载工具,并用提取码解锁。接着,打开工具的批量复制功能,将待整理的图片文件拖入“来源路径”,目标文件夹拖入“终点路径”。通过层级过滤排除不需要的路径。然后,利用多级匹配设置,提取文件名和路径中的关键词,如“动物”、“小型”、“食草”等,设置复制后的文件重命名规则。最后,执行批量复制,完成文件的智能分类与命名。整个过程旨在根据文件的原始分类信息,自动将其移动到相应的新目录结构下。
|
2月前
如何把多个文件(夹)向上移动1层(或多层)(在批量复制前或后进行)
该文介绍了如何使用一个工具将四个文件夹内的所有文件合并到另一个文件夹中。工具可以从百度网盘或蓝奏云下载,提取码分别为qwu2和2r1z。操作步骤包括:打开工具,选择文件批量复制,设置源路径上移,确定设置后将文件夹拖入,导入文件,移除不需要的文件夹路径,最后执行移动操作。移动过程中会删除空文件夹,并在回收站中可见。
|
8月前
xxlsso框架设置不需要过滤的路径
xxlsso框架设置不需要过滤的路径
24 0
|
JSON 前端开发 数据格式
djangVue_前后端配置动态的数据字段标
前后端配置动态的数据字段标签(django_vue)
58 1
|
移动开发 编解码 资源调度
分集与路径合并方式
分集与路径合并方式
133 0
分集与路径合并方式
|
数据采集 移动开发 数据可视化
空间转录组|Load10X_Spatial函数修改适配多形式数据 + 空转标准流程
空间转录组|Load10X_Spatial函数修改适配多形式数据 + 空转标准流程
459 0
无法找到可用的配置文件来构建预处理器
无法找到可用的配置文件来构建预处理器
68 0
【TP5】一个表里边有多个关联怎么使用预加载
【TP5】一个表里边有多个关联怎么使用预加载
79 0
【TP5】一个表里边有多个关联怎么使用预加载