当前位置: 首页> 汽车> 新车 > ArcGIS Pro SDK (七)编辑 7 操作Blob字段

ArcGIS Pro SDK (七)编辑 7 操作Blob字段

时间:2025/7/10 2:54:56来源:https://blog.csdn.net/szy13323042191/article/details/140093366 浏览次数: 2次

ArcGIS Pro SDK (七)编辑 7 操作Blob字段

目录

  • ArcGIS Pro SDK (七)编辑 7 操作Blob字段
    • 1 使用属性检查器读取和写入 Blob 字段
    • 2 在回调中使用行游标读取和写入 Blob 字段

环境:Visual Studio 2022 + .NET6 + ArcGIS Pro SDK 3.0

1 使用属性检查器读取和写入 Blob 字段

QueuedTask.Run(() =>{// 将选定要素加载到检查器中var selectedFeatures = MapView.Active.Map.GetSelection();var insp = new Inspector();insp.Load(selectedFeatures.ToDictionary().Keys.First(), selectedFeatures.ToDictionary().Values.First());// 读取 Blob 字段并保存到文件var msw = new MemoryStream();msw = insp["Blobfield"] as MemoryStream;using (FileStream file = new FileStream(@"d:\temp\blob.jpg", FileMode.Create, FileAccess.Write)){msw.WriteTo(file);}// 将文件读取到内存流中var msr = new MemoryStream();using (FileStream file = new FileStream(@"d:\images\Hydrant.jpg", FileMode.Open, FileAccess.Read)){file.CopyTo(msr);}// 将内存流中的数据放入 Blob 字段并保存到要素var op = new EditOperation();op.Name = "Blob Inspector";insp["Blobfield"] = msr;op.Modify(insp);op.Execute();});

2 在回调中使用行游标读取和写入 Blob 字段

QueuedTask.Run(() =>{var editOp = new EditOperation();editOp.Name = "Blob Cursor";var featLayer = MapView.Active.Map.FindLayers("Hydrant").First() as FeatureLayer;editOp.Callback((context) =>{using (var rc = featLayer.GetTable().Search(null, false)){while (rc.MoveNext()){using (var record = rc.Current){// 读取 Blob 字段并保存到文件var msw = new MemoryStream();msw = record["BlobField"] as MemoryStream;using (FileStream file = new FileStream(@"d:\temp\blob.jpg", FileMode.Create, FileAccess.Write)){msw.WriteTo(file);}// 将文件读取到内存流中var msr = new MemoryStream();using (FileStream file = new FileStream(@"d:\images\Hydrant.jpg", FileMode.Open, FileAccess.Read)){file.CopyTo(msr);}// 将内存流中的数据放入 Blob 字段并保存到要素record["BlobField"] = msr;record.Store();}}}}, featLayer.GetTable());editOp.Execute();});
关键字:ArcGIS Pro SDK (七)编辑 7 操作Blob字段

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: