/// <summary>
/// 得到输入点在输入图层上的最近点
/// </summary>
/// <param name="randomPoints">输入的点,注意小数位数不能太长,具体支持多长没有测试,我用小数点2位可以成功,但是七八位肯定不行</param>
/// <param name="feaPoints">输出在featureclass上距离最近的要素,这里是点类型输出的是点</param>
/// <param name="length">输入点到featureclass上最近点的距离</param>
/// <returns></returns>
public bool NearestPoint(IPoint[] randomPoints, out IPoint[] feaPoints, out double length)
{
feaPoints = new IPoint[randomPoints.Length];
length = ;
try
{
fd = (LinkReady.ReadPipeLineWorkspace() as IFeatureWorkspace).OpenFeatureDataset(LY.UG.Common.DictionaryConfig.DatasetName["道路网络数据集名称"]);//("SDE.地下管线");
nc = fd as INetworkCollection;
IFeatureClass feaRoadJunction = (fd as IFeatureClassContainer).get_ClassByName(LY.UG.Common.DictionaryConfig.DatasetName["道路网络点图层"]); int[] feaID = new int[randomPoints.Length];
double[] feaDis = new double[randomPoints.Length];
IFeatureIndex pFeatureIndex = new FeatureIndex();
IIndexQuery pIndexQuery;
IGeoDataset geodataset = (IGeoDataset)feaRoadJunction; ITrackCancel trackCancel = new TrackCancel();
pFeatureIndex.FeatureClass = feaRoadJunction;//.setFeatureClassByRef(pFeatureClass1); pFeatureIndex.Index(trackCancel, geodataset.Extent);
pIndexQuery = pFeatureIndex as IIndexQuery;
for (int i = ; i < randomPoints.Length; i++)
{
pIndexQuery.NearestFeature(randomPoints.GetValue(i) as IPoint, out feaID[i], out feaDis[i]);
feaPoints[i] = new PointClass();
feaPoints[i] = feaRoadJunction.GetFeature(feaID[i]).ShapeCopy as IPoint;
length = length + feaDis[i];
} return true;
}
catch (Exception ee)
{
return false;
}
}

 

最新文章

  1. linux安装php
  2. 浅谈RSA加密算法
  3. [笔记]--Python字符串处理
  4. 可接受多个值的文件上传字段HTML5新特性
  5. Java语言编写计算器(简单的计算器)
  6. Android中对闹钟Alarm的事件处理
  7. 将前台input中的数据异步传到后台并存入数据库
  8. Django:同一个app支持多个数据库
  9. rem 自适应适配方法
  10. F3D模式规则详解
  11. 机器学习之决策树_CART算法
  12. 常见Chrome 插件
  13. echart图表
  14. SpringAOP基础 - 静态代理设计模式
  15. 要使用C#实现一个ActiveX控件
  16. C#中DllImport用法汇总
  17. shell统计各省的百强县
  18. java NIO(转载)
  19. 美团Java实习面试经历(拿到Offer)
  20. Qt 使用irrlicht(鬼火)3D引擎

热门文章

  1. Android文件选择器的实例分享
  2. JNI 系统钩子
  3. android UI进阶之实现listview中checkbox的多选与记录
  4. PHP实现Web Service(转)
  5. requestFileSystem is undefined
  6. linux_nand_driver
  7. c语言例子递归与整数逆序
  8. c语言数组的初始化
  9. Partitioning, Shuffle and sort
  10. CSS skills: 6) auto hide the top bar javascript