zoukankan      html  css  js  c++  java
  • 找个输入IPoint在某个FeatureClass上距离最近的要素

     

     

     1 /// <summary>
     2         /// 得到输入点在输入图层上的最近点
     3         /// </summary>
     4         /// <param name="randomPoints">输入的点,注意小数位数不能太长,具体支持多长没有测试,我用小数点2位可以成功,但是七八位肯定不行</param>
     5         /// <param name="feaPoints">输出在featureclass上距离最近的要素,这里是点类型输出的是点</param>
     6         /// <param name="length">输入点到featureclass上最近点的距离</param>
     7         /// <returns></returns>
     8         public bool NearestPoint(IPoint[] randomPoints, out IPoint[] feaPoints, out double length)
     9         {
    10             feaPoints = new IPoint[randomPoints.Length];
    11             length = 0;
    12             try
    13             {
    14                 fd = (LinkReady.ReadPipeLineWorkspace() as IFeatureWorkspace).OpenFeatureDataset(LY.UG.Common.DictionaryConfig.DatasetName["道路网络数据集名称"]);//("SDE.地下管线");
    15                 nc = fd as INetworkCollection;
    16                 IFeatureClass feaRoadJunction = (fd as IFeatureClassContainer).get_ClassByName(LY.UG.Common.DictionaryConfig.DatasetName["道路网络点图层"]);
    17 
    18                 int[] feaID = new int[randomPoints.Length];
    19                 double[] feaDis = new double[randomPoints.Length];
    20                 IFeatureIndex pFeatureIndex = new FeatureIndex();
    21                 IIndexQuery pIndexQuery;
    22                 IGeoDataset geodataset = (IGeoDataset)feaRoadJunction;
    23 
    24                 ITrackCancel trackCancel = new TrackCancel();
    25                 pFeatureIndex.FeatureClass = feaRoadJunction;//.setFeatureClassByRef(pFeatureClass1);
    26 
    27                 pFeatureIndex.Index(trackCancel, geodataset.Extent);
    28                 pIndexQuery = pFeatureIndex as IIndexQuery;
    29                 for (int i = 0; i < randomPoints.Length; i++)
    30                 {
    31                     pIndexQuery.NearestFeature(randomPoints.GetValue(i) as IPoint, out feaID[i], out feaDis[i]);
    32                     feaPoints[i] = new PointClass();
    33                     feaPoints[i] = feaRoadJunction.GetFeature(feaID[i]).ShapeCopy as IPoint;
    34                     length = length + feaDis[i];
    35                 }
    36 
    37                 return true;
    38             }
    39             catch (Exception ee)
    40             {
    41                 return false;
    42             }
    43         }

     

  • 相关阅读:
    Ubuntu MP4转MP3 软件:soundconverter
    Jupyter 中添加conda环境
    Pandas 比较两个 DataFrames 是否相同
    苹果ID不能登陆:The action could not be completed. Try again
    awsome node.js
    Cygwin
    library dep
    process
    MSCV version
    cmake_host_system_information
  • 原文地址:https://www.cnblogs.com/fatherZyl/p/3642885.html
Copyright © 2011-2022 走看看