摘要:
/*使用OleDb连接*/using System.Data.OleDb;public int TransferData(string excelFile, string sheetName, string connectionString,int WeekId){ DataSet ds = new DataSet(); string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + excelFile + "';Extended Properties='Excel 8 阅读全文
摘要:
/* 以下代码实现的是矢量数据的更新,删除*//* 注意可以用store,但是效率比较低,每次都写一下文件,不如一次性flush一下*//*首先定义游标,然后.NextFeature() 依次执行,但是注意select产生的游标不能应用于update 和 Insert*//*代码比较乱,包含添加、删除、更新三个方面的操作,没有注释掉的是更新操作,查询之前的文章介绍过*/#region 修改字段的值IDataset dataset = pFlayerClass as IDataset; IWorkspace workspace = dataset.Workspace; IWorkspaceEdi 阅读全文
摘要:
System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();stopwatch.Start(); // 开始监视代码运行时间/*代码放在这里*/stopwatch.Stop(); // 停止监视TimeSpan timespan = stopwatch.Elapsed; // 获取当前实例测量得出的总时间double seconds = timespan.TotalSeconds; // 总秒数MessageBox.Show(seconds.ToString()+"秒"); 阅读全文
摘要:
public void CreateNewLayer(AxMapControl ax, string layerName, esriGeometryType layerType){ // 空间参考系 得到当前地图的空间参考系 ISpatialReference spatialReference = ax.ActiveView.FocusMap.SpatialReference; // 设定保持的路径 string strShapeFolder = @"F:\fuzhou\"; // 设定图层文件名 string strShapeFile = layerName + &quo 阅读全文
摘要:
// 定义圆的中心点IPoint point = new PointClass();point.X = 119.302302426605;point.Y = 26.0989696929962;// 半径double radius = 0.001;// 圆构造器ICircularArc circularArc = new CircularArcClass();IConstructCircularArc constructCircularArc = circularArc as IConstructCircularArc;// 开始画圆constructCircularArc.ConstructC 阅读全文
摘要:
// 思路将feature加入至集合IFeatureCursor pFeatureCursor = pFeatureLayer.Search(null, true);IFeature pFeature = pFeatureCursor.NextFeature();ISymbol symbol = CreateSimpleSymbol(pFeature.Shape.GeometryType);if (pFeature != null){IGeometryCollection pGeometryCollention =new PolygonClass();object missing = Type 阅读全文
摘要:
// 将ILayer转换为IFeaturelayer,为了对图层上的要素进行编辑ILayer pLayer = GetGallery(ActiveGallery);IFeatureLayer pFeatureLyr = pLayer as IFeatureLayer;// 定义一个要素集合,并获取图层的要素集合IFeatureClass pFeatCls = pFeatureLyr.FeatureClass;// 定义一个实现添加要素的接口实例,并该实例作用于当前图层的要素集IFeatureClassWrite fr = (IFeatureClassWrite)pFeatCls;// 定义一个 阅读全文
摘要:
/*查询与某路段的相交路段*/// 矢量数据集IFeatureClass pFeatureClass = pFeatLyr.FeatureClass;// 空间查询器ISpatialFilter pFilter = new SpatialFilterClass();// 查询的空间数据类型 点?线?面?pFilter.Geometry = polyline;pFilter.GeometryField = "Shape";// 空间关系 相交 相接等pFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects 阅读全文
摘要:
/*按某属性值查询,并将查询结果显示在一个新的图层中*/// 将图层声明为矢量图层IFeatureLayer pFeatureLayer = GetGallery(gallery) as IFeatureLayer;// 创建选择集IFeatureSelection pFeatSel;pFeatSel = pFeatureLayer as IFeatureSelection;// 设定选定的颜色Color color = this.SelectedLineColor;pFeatSel.SelectionColor = GetRGB(color.R, color.G, color.B);// 创 阅读全文
摘要:
矢量数据属性值的查询// 矢量点数据IPoint pt = pFeature.Shape as IPoint;// 得到矢量点的 x,ydouble x = pt.x;double y = pt.y;// 矢量属性数据的查询int fid;for (k = 0; k < pFeature.Table.Fields.FieldCount; k++){ if (pFeature.Table.Fields.get_Field(k).Name == "FID") fid=(int)pFeature.get_Value(k); break;} 阅读全文