How can I modify attributes when duplicating a Pro Fabric Parcel from one Parcel type to another in the SDK?

568
2
Jump to solution
03-04-2021 01:14 PM
MichaelSnook
Occasional Contributor III

Hi All,

I am using the simple SDK sample for duplicating a parcel from one type to another in the Pro fabric but I'm stumped on how to go about modifying the attributes of the duplicated parcels (without getting the id and modifying it after it has been duplicated).  Is it possible to push modified attributes before the duplication happens?  Any help would be great!

Thanks

Mike

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
MichaelSnook
Occasional Contributor III
2 Replies
MichaelSnook
Occasional Contributor III
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Hi Michael,

 I am working on a ParcelFabric API sample for the Dev Summit.  The sample will be published with the 2.8 Community samples.   The sample handles attribution of parcel features which is what you were asking about.  I found that I had to process one parcel at a time in order to perform parcel specific attribution.  In my case I wanted to simply add a parcel identification number to each feature (line, polygon) that is part of a parcel.  I used the CopyParcelLinesToParcelType API method to 'copy' a parcel to a different parcel type (lot to tax parcel in my case).  CopyParcelLinesToParcelType will actually copy existing attribution (as an option), but in case you need to change attribution for the newly created features you can use the following snippet:

var editOper = new EditOperation()
{
	Name = "Copy Parcels to Tax Type",
	ProgressMessage = "Copy To Tax Parcel Type ...",
	ShowModalMessageAfterFailure = false,
	SelectNewFeatures = false,
	SelectModifiedFeatures = false
};
//add the source parcel source, and feature ids to a new KeyValuePair
var polyIds = // List of Object Ids that are part of one lot parcel's polygon feature
var kvp = new KeyValuePair<MapMember, List<long>>(lotLayer, polyIds);
var sourceParcelFeatures = new List<KeyValuePair<MapMember, List<long>>> { kvp };
// This is performed for each parcel
var parcelCopyToken = editOper.CopyParcelLinesToParcelType(_parcelFabricLayer, sourceParcelFeatures, _taxLayerLines, _taxLayerPolys, false, true, true);
if (!editOper.Execute()) return editOper.ErrorMessage;
var createdParcelFeatures = parcelCopyToken.CreatedFeatures;
var modifiedParcelFeatures = parcelCopyToken.ModifiedFeatures;
System.Diagnostics.Debug.WriteLine($@"CopyParcelLinesToParcelType:");
if (parcelCopyToken.CreatedFeatures != null)
{
  foreach (var created in parcelCopyToken.CreatedFeatures)
    System.Diagnostics.Debug.WriteLine($@"Mapmember: {created.Key} created: {created.Value.Count()}");
}
if (parcelCopyToken.ModifiedFeatures != null)
{
  foreach (var modified in parcelCopyToken.ModifiedFeatures)
    System.Diagnostics.Debug.WriteLine($@"Mapmember: {modified.Key} modified: {modified.Value.Count()}");
}

If I use the snippet above and select a single 'lot' parcel as shown here:

SelectLot.png

I get the following diagnostic output after the selected Lot parcel was copied into my Tax parcels:

CopyParcelLinesToParcelType:
Mapmember: Tax_Lines created: 7
Mapmember: Tax created: 1

To update attributes of the new Tax_Lines & Tax features I use the Inspector to perform the attribution for each feature:

var editOperUpdate = editOper.CreateChainedOperation();
Dictionary<string, object> ParcelAttributes = new Dictionary<string, object>();
foreach (KeyValuePair<MapMember, List<long>> kvp in parcelCopyToken.CreatedFeatures)
{
  var mapMember = kvp.Key;
  var oids = kvp.Value;
  foreach (long oid in oids)
  {
    var insp = new Inspector();
    insp.Load(mapMember, oid);
    ParcelAttributes.Clear();
    ParcelAttributes.Add(FieldNameTmk, tmk);   // column name & new data
    ParcelAttributes.Add(..., ...);
    editOperUpdate.Modify(mapMember, oid, ParcelAttributes);
  }
}
if (!editOperUpdate.Execute())
  return editOperUpdate.ErrorMessage;