博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
arcengine,深入理解游标Cursors,实现数据的快速查找,插入,删除,更新
阅读量:6018 次
发布时间:2019-06-20

本文共 2468 字,大约阅读时间需要 8 分钟。

风过无痕 原文 

 

深入理解游标Cursors,实现数据的快速查找,插入,删除,更新

1、查找数据Search Cursors

//by yl 2008.7.7

IEnvelope envelope = new EnvelopeClass();envelope.PutCoords(508786, 681196, 513033, 684341);ISpatialFilter spatialFilter = new SpatialFilterClass();spatialFilter.Geometry = envelope;String shpFld = featureClass.ShapeFieldName;spatialFilter.GeometryField = shpFld;spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;IQueryFilter queryFilter = new QueryFilterClass();queryFilter = (IQueryFilter)spatialFilter;IFeatureCursor searchCursor = featureClass.Search(queryFilter, true);//只查询,true快一些IFeature feature = searchCursor.NextFeature();int n = 0;while (feature != null){    n++;    feature = baseCursor.NextFeature();}

 

 

2、插入数据Insert Cursors—目前数据插入最快的方法   

//by yl 2008.7.7

IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer();IFeatureCursor featureCursor = featureClass.Insert(true);object featureOID;         featureBuffer.set_Value(featureBuffer.Fields.FindField("InstBy"), "B Pierce");for (int ic = 0; ic < 99; ic++) {         featureBuffer.Shape = geometry   featureOID = featureCursor.InsertFeature(featureBuffer);}featureBuffer.set_Value(featureBuffer.Fields.FindField("InstBy"), "K Johnston");for (int ic = 0; ic < 99; ic++){     featureBuffer.Shape = geometry     featureOID = featureCursor.InsertFeature(featureBuffer);}featureCursor.Flush();

 

3、 数据删除 delete   

//by yl 2008.7.7

IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("Parcels"); IQueryFilter queryFilter = new QueryFilterClass();queryFilter.WhereClause = "ZONING_S = 'R'";IFeatureCursor updateCursor = featureClass.Update(queryFilter, false);IFeature feature = updateCursor.NextFeature(); int m = 0;while (feature != null){    m++;    updateCursor.DeleteFeature(feature);    feature = updateCursor.NextFeature();}

 

 

4、数据更新 update   

 

//by yl landgis@126.com yanleigis@21cn.com 2008.7.7IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("Parcels");// restrict the number of features to be updated.IQueryFilter queryFilter = new QueryFilterClass();queryFilter.WhereClause = "ZONING_S = 'U'"; // use IFeatureClass::Update to populate IFeatureCursorIFeatureCursor updateCursor = featureClass.Update(queryFilter, false);int fieldindex = featureClass.FindField("ZONING_S");IFeature feature = updateCursor.NextFeature();int m = 0;while (feature != null){    m++;    feature.set_Value(fieldindex, "X");    updateCursor.UpdateFeature(feature);    feature = updateCursor.NextFeature();}

 

 

 

转载地址:http://srjqx.baihongyu.com/

你可能感兴趣的文章
silverlight:datagrid滚动
查看>>
不能将参数 1 从“const char [5]”转换为“LPCTSTR”解决
查看>>
mysql基础入门
查看>>
hadoop
查看>>
送给自己的几句话
查看>>
64位win2008下IIS未开启32位支持导致DLL无法加载问题
查看>>
【原创】Algorithms:原地归并排序
查看>>
VGA的verilog驱动
查看>>
uboot学习之一-----源码配置
查看>>
谷歌地球如何下载使用高程数据
查看>>
JsonCpp Documentation
查看>>
Facebook和Google如何激发工程师的创造力
查看>>
HttpClient
查看>>
别再为了this发愁了------JS中的this机制
查看>>
HDU 5272 : Dylans loves numbers
查看>>
FORM表单
查看>>
【CXF】基于CXF Web Service:Apache CXF简单部署
查看>>
大数据之hadoop框架知识
查看>>
bootstrap 2.3版与3.0版的使用区别
查看>>
数据结构与算法
查看>>