public void Load( MapMember member, IEnumerable<long> oidSet )
Public Overloads Sub Load( _ ByVal member As MapMember, _ ByVal oidSet As IEnumerable(Of Long) _ )
Parameters
- member
- mapMember
- oidSet
- An IEnumerable containing the object IDs
public void Load( MapMember member, IEnumerable<long> oidSet )
Public Overloads Sub Load( _ ByVal member As MapMember, _ ByVal oidSet As IEnumerable(Of Long) _ )
| Exception | Description |
|---|---|
| ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
// Modifies multiple features in the specified feature layer by updating their attributes. await QueuedTask.Run(() => { //Search by attribute var queryFilter = new QueryFilter() { WhereClause = "OBJECTID < 1000000" }; //Create list of oids to update var oidSet = new List<long>(); using (var rc = featureLayer.Search(queryFilter)) { while (rc.MoveNext()) { using var record = rc.Current; oidSet.Add(record.GetObjectID()); } } //create and execute the edit operation var modifyFeatures = new EditOperation { Name = "Modify features", ShowProgressor = true }; var multipleFeaturesInsp = new Inspector(); multipleFeaturesInsp.Load(featureLayer, oidSet); multipleFeaturesInsp["MOMC"] = 24; modifyFeatures.Modify(multipleFeaturesInsp); if (!modifyFeatures.IsEmpty) { var result = modifyFeatures.ExecuteAsync(); //Execute and ExecuteAsync will return true if the operation was successful and false if not } });
{
var oidSet = new List<long>();
var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
//find layer
var disLayer = ArcGIS.Desktop.Mapping.MapView.Active.Map.FindLayers("Distribution mains").FirstOrDefault() as BasicFeatureLayer;
//Search by attribute
var filter = new ArcGIS.Core.Data.QueryFilter { WhereClause = "CONTRACTOR = 'KCGM'" };
var oids = new List<long>();
using (var rc = disLayer.Search(filter))
{
//Create list of oids to update
while (rc.MoveNext())
{
using (var record = rc.Current)
{
oidSet.Add(record.GetObjectID());
}
}
}
//Create edit operation
var modifyOp = new EditOperation() { Name = "Update date" };
// load features into inspector and update field
var dateInsp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
dateInsp.Load(disLayer, oids);
dateInsp["InspDate"] = "9/21/2013";
// modify and execute
modifyOp.Modify(insp);
if (!modifyOp.IsEmpty)
{
var result = modifyOp.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
}
}
// Demonstrates how to use the <see cref="ArcGIS.Desktop.Editing.EditOperation"/> methods <see var selectionMapView = MapView.Active; if (selectionMapView == null) return; await QueuedTask.Run(() => { // SetOnUndone, SetOnRedone and SetOnComitted can be used to manage // external actions(such as writing to a log table) that are associated with // each edit operation. //get selected feature and update attribute var selectedFeatures = selectionMapView.Map.GetSelection(); var testInspector = new Inspector(); testInspector.Load(selectedFeatures.ToDictionary().Keys.First(), selectedFeatures.ToDictionary().Values.First()); testInspector["Name"] = "test"; //create and execute the edit operation var updateTestField = new EditOperation() { Name = "Update test field" }; updateTestField.Modify(testInspector); //actions for SetOn... updateTestField.SetOnUndone(() => { //Sets an action that will be called when this operation is undone. Debug.WriteLine("Operation is undone"); }); updateTestField.SetOnRedone(() => { //Sets an action that will be called when this edit operation is redone. Debug.WriteLine("Operation is redone"); }); updateTestField.SetOnComitted(b => { // Sets an action that will be called when this edit operation is committed. Debug.WriteLine("Operation is committed"); }); if (!updateTestField.IsEmpty) { var result = updateTestField.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not } });
// Retrieves the value of a specific attribute and the geometry of the first selected feature from the provided selection set. await QueuedTask.Run(() => { // get the first layer and its corresponding selected feature OIDs var firstSelectionSet = selectedFeatures.ToDictionary().First(); // create an instance of the inspector class var inspector = new Inspector(); // load the selected features into the inspector using a list of object IDs inspector.Load(firstSelectionSet.Key, firstSelectionSet.Value); //get the value of var pscode = inspector["STATE_NAME"]; var myGeometry = inspector.Shape; });
await QueuedTask.Run(() => { // get selected feature into inspector var selectedFeatures = activeMap.GetSelection(); var insp = new Inspector(); insp.Load(selectedFeatures.ToDictionary().Keys.First(), selectedFeatures.ToDictionary().Values.First()); // read a blob field and save to a file var msw = new MemoryStream(); msw = insp["BlobField"] as MemoryStream; using (FileStream file = new(@"d:\temp\blob.jpg", FileMode.Create, FileAccess.Write)) { msw.WriteTo(file); } // read file into memory stream var msr = new MemoryStream(); using (FileStream file = new(@"d:\images\Hydrant.jpg", FileMode.Open, FileAccess.Read)) { file.CopyTo(msr); } //put the memory stream in the blob field and save to feature var op = new EditOperation() { Name = "Blob Inspector" }; insp["Blobfield"] = msr; op.Modify(insp); if (!op.IsEmpty) { var result = op.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not } });
var readRasterMapView = MapView.Active; if (readRasterMapView == null) return; await QueuedTask.Run(() => { var sel = readRasterMapView.Map.GetSelection(); //Read a raster from a raster field as an InteropBitmap //the bitmap can then be used as an imagesource or written to disk var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); insp.Load(sel.ToDictionary().Keys.First(), sel.ToDictionary().Values.First()); var ibmp = insp["Photo"] as System.Windows.Interop.InteropBitmap; });
var writeRasterMapView = MapView.Active; if (writeRasterMapView == null) return; await QueuedTask.Run(() => { var sel = writeRasterMapView.Map.GetSelection(); //Insert an image into a raster field //Image will be written with no compression var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); insp.Load(sel.ToDictionary().Keys.First(), sel.ToDictionary().Values.First()); insp["Photo"] = @"e:\temp\Hydrant.jpg"; var op = new EditOperation() { Name = "Raster Inspector" }; op.Modify(insp); if (!op.IsEmpty) { var result = op.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not } });
var compressedRasterMapView = MapView.Active; if (compressedRasterMapView == null) return; await QueuedTask.Run(() => { //Open the raster dataset on disk and create a compressed raster value dataset object var dataStore = new ArcGIS.Core.Data.FileSystemDatastore(new ArcGIS.Core.Data.FileSystemConnectionPath(new Uri(@"e:\temp"), ArcGIS.Core.Data.FileSystemDatastoreType.Raster)); using (var fileRasterDataset = dataStore.OpenDataset<ArcGIS.Core.Data.Raster.RasterDataset>("Hydrant.jpg")) { var storageDef = new ArcGIS.Core.Data.Raster.RasterStorageDef(); storageDef.SetCompressionType(ArcGIS.Core.Data.Raster.RasterCompressionType.JPEG); storageDef.SetCompressionQuality(90); var rv = new ArcGIS.Core.Data.Raster.RasterValue(); rv.SetRasterDataset(fileRasterDataset); rv.SetRasterStorageDef(storageDef); var sel = compressedRasterMapView.Map.GetSelection(); //insert a raster value object into the raster field var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); insp.Load(sel.ToDictionary().Keys.First(), sel.ToDictionary().Values.First()); insp["Photo"] = rv; var op = new EditOperation() { Name = "Raster Inspector" }; op.Modify(insp); if (!op.IsEmpty) { var result = op.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not } } });
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)