ArcGIS Engine效率探究之(一)属性的读取
2015-08-20 09:55
447 查看
原文链接:/article/10309803.html
对属性表的统计函数时,发现执行速度奇慢无比,百思不得其解,其实算法并不复杂,后来逐句排查终于发现竟是 ArcGIS
Engine 的函数读取属性值的问题。
在获取属性表的值时有多种方法:
方法一:
实例测试:
对属性表的统计函数时,发现执行速度奇慢无比,百思不得其解,其实算法并不复杂,后来逐句排查终于发现竟是 ArcGIS
Engine 的函数读取属性值的问题。
在获取属性表的值时有多种方法:
方法一:
ITable pTable = pFeatureClass as ITable; pValue = pTable.GetRow(i).get_Value(3);方法二:
IFeatureCursor pFCursor = pFeatureClass.Search(new QueryFilterClass(), false); IFeature pFeature = pFCursor.NextFeature(); if (pFeature == null) return null; pValue = pFeature.get_Value(pIndex); pFeature = pFCursor.NextFeature();方法二明显要快于方法一
实例测试:
//目标是想将原数据库中的点信息(x,y经纬度坐标,度格式),添加到FeatureClass中,数据库中大概有10000条数据,全部添加到FeatureClass中大概需
//要半小时以上 DataSet ds = loadExcel("d://aaa.xls"); IFeature feature = featureClass.CreateFeature(); IFields fields = featureClass.Fields; for(int i=0;i<ds.Tables[0].Rows.Count;i++) { DataRow row = ds.Tables[0].Rows[i]; string xl = Convert.ToString(row[0]); string x = Convert.ToDouble(row[1]); string y = Convert.ToDouble(row[2]); //....其它数据库中字段 //创建点对象 IPoint point = new PointClass(); point.X = x; point.Y = y; //设置Fields域 feature.set_Value(fields.FindField("线路"),xl); feature.set_Value(fields.FindField("经度"),x); feature.set_Value(fields.FindField("纬度"),y); //保存点对象 feature.Shape = point; feature.Store(); } //改进后: DataSet ds = loadExcel("d://aaa.xls") IFeatureBuffer featureBuffer;// IFeatureCursor cur = featureClass.Insert(true); IPoint point; IFields fields = featureClass.Fields; for(int i=0;i<ds.Tables[0].Rows.Count;i++) { DataRow row = ds.Tables[0].Rows[i]; string xl = Convert.ToString(row[0]); string x = Convert.ToDouble(row[1]); string y = Convert.ToDouble(row[2]); //....其它数据库中字段 //创建点对 point = new PointClass(); point.X = x; point.Y = y; featureBuffer = featureClass.CreateFeatureBuffer(); //设置Fields域 featureBuffer.set_Value(fields.FindField("线路"),xl); featureBuffer.set_Value(fields.FindField("经度"),x); featureBuffer.set_Value(fields.FindField("纬度"),y); //保存点对象 featureBuffer.Shape = point; cur.InsertFeature(featureBuffer); } //可以看出改进后使用了eatureClass.CreateFeatureBuffer方法,使效率大大提高。
相关文章推荐
- Ubuntu新添加用户无法sudo问题的解决:修改sudoers
- android的listview分组显示的时候layout_marginTop失效的解决办法
- QT QTableView用法小结(设置单元格字体颜色,文本字体...)
- LeetCode OJ 242:Valid Anagram
- SPOJ AMR11E - Distinct Primes 10232【素数打表】
- C#模拟PrtScn实现截屏预备知识--keybd_event使用方法
- 17、SQL Server 备份和还原
- jvm基础知识二
- 分析网站建设销售们在和客户沟通中的录音行为
- Apache与Tomcat整合
- Zabbix快速部署
- 学习迭代器
- LVM常见案例
- 第一次开通博客,以后多多关照!
- iOS 面试常见问题总结2
- Photoshop图层混合(Layer Blending)模式的算法实现
- 修改initrd方法
- ubuntu14.04下配置jdk环境
- 修改initrd方法
- linux 多行操作