FRAMES | NO FRAMES |
Adds features to a repository feature layer.
Availability: Business Analyst Server 9.3.1 SP1.
bool AddFeatures ( AddFeaturesParameters Parameters );
Parameter | Description |
---|---|
Parameters | Configuration options for the utility. Type AddFeaturesParameters. |
Variable of type Boolean whose value is always true.
This method allows user to add features to a feature layer having a point or polygon geometry. The SourceLayer and DestinationItem layers should have the same type of geometry and the same spatial reference.
While adding features to the destination layer, alien attributes of features are ignored. If the destination layer contains attributes that are missing in the source layer, its values for added features are initialized to default values.
When added to the destination layer, features of the source layer receive serial values for the Object ID attribute starting after the last feature Object ID in the destination layer. Since Object ID attribute value is automatically assigned to new features of the destination layer, it has no sence to specify the Object ID attribute for features of the source feature layer. If this attribute is specified, it is ignored.
NOTE: The name of the Object ID attribute of features depends on a feature class workspace type used. Typical names for Object ID are "FID", "OID", or "OBJECTID".
The example below creates a store feature layer in the repository by geocoding store address records and adds more store feature records into this layer.
NOTE: The signature of the BAServerHelper.AddFeatures method is modified against this method—a source feature record set and an output folder item are passed in parameters instead of AddFeaturesParameters type.
C# |
// Instantiate the BAServerHelper class to access analysis methods BAServerHelper baServerHelper = new BAServerHelper(); baServerHelper.ActiveDatasetID = "USA_ESRI"; // Optional parameter baServerHelper.IsFullErrorMessage = true; // Default is false RenderingParameters imageOptions; TaskOutputType[] outputOptions; esriFolderItem outputLayer; // ========= STEP 1: Create a record set by store addresses RecordSetByAddress[] storeAddresses = new RecordSetByAddress[3]; storeAddresses[0] = new RecordSetByAddress(); storeAddresses[0].Name = "pizza1"; storeAddresses[0].Description = "Rush Street Store"; storeAddresses[0].StoreID = "1"; storeAddresses[0].Address = "730 N. Rush St."; storeAddresses[0].City = "Chicago"; storeAddresses[0].State = "IL"; storeAddresses[0].ZIP = "60611"; storeAddresses[1] = new RecordSetByAddress(); storeAddresses[1].Name = "pizza2"; storeAddresses[1].Description = "Clark Street Store"; storeAddresses[1].StoreID = "2"; storeAddresses[1].Address = "2121 N. Clark St."; storeAddresses[1].City = "Chicago"; storeAddresses[1].State = "IL"; storeAddresses[1].ZIP = "60614"; storeAddresses[2] = new RecordSetByAddress(); storeAddresses[2].Name = "pizza3"; storeAddresses[2].Description = "31st Street Store"; storeAddresses[2].StoreID = "3"; storeAddresses[2].Address = "4254 W. 31st St."; storeAddresses[2].City = "Chicago"; storeAddresses[2].State = "IL"; storeAddresses[2].ZIP = "60623"; TaskResultOutput recordSetResult = baServerHelper.CreateRecordSetByAddresses(storeAddresses, esriFolderType.esriFolderStoreLayers); // Create a table from the address record set TableData tableData = new TableData(); tableData.RecordSet = recordSetResult.RecordSet; GeocodeData geocodeData = new GeocodeData(); geocodeData.Table = tableData; // ========= STEP 2: Geocode the record set with stores CustomerStoreSetupByGeocodeTableParameters geocodeParameters = new CustomerStoreSetupByGeocodeTableParameters(); // Set specific analysis parameters geocodeParameters.GeocodeCustomers = false; geocodeParameters.GeocodeData = geocodeData; geocodeParameters.NameField = "NAME"; geocodeParameters.StoreIDField = "STORE_ID"; // Set other parameters imageOptions = null; // DEBUG outputOptions = new TaskOutputType[] { TaskOutputType.GetFeatureClass }; //outputOptions = new TaskOutputType[0]; // Empty output! // In general, a non-null esriFolderItem is specified to save a newly-created // item to the server-side repository or to reference an existing item in it. outputLayer = new esriFolderItem(); outputLayer.folderType = esriFolderType.esriFolderStoreLayers; outputLayer.itemName = "storeLayer_AddFeatures"; outputLayer.workspaceName = "Default Workspace"; outputLayer.projectName = "Default Project"; // TODO: remove debugging TaskResultOutput r = baServerHelper.CustomerStoreSetupByGeocodeTable(geocodeParameters, imageOptions, outputOptions, outputLayer); // ========= STEP 3: Create another record set by store addresses storeAddresses = new RecordSetByAddress[3]; storeAddresses[0] = new RecordSetByAddress(); storeAddresses[0].Name = "pizza4"; storeAddresses[0].Description = "Wells Street Store"; storeAddresses[0].StoreID = "4"; storeAddresses[0].Address = "439 N. Wells St."; storeAddresses[0].City = "Chicago"; storeAddresses[0].State = "IL"; storeAddresses[0].ZIP = "60610"; storeAddresses[1] = new RecordSetByAddress(); storeAddresses[1].Name = "pizza5"; storeAddresses[1].Description = "Ohio Street Store"; storeAddresses[1].StoreID = "5"; storeAddresses[1].Address = "29 E. Ohio St."; storeAddresses[1].City = "Chicago"; storeAddresses[1].State = "IL"; storeAddresses[1].ZIP = "60611"; storeAddresses[2] = new RecordSetByAddress(); storeAddresses[2].Name = "pizza6"; storeAddresses[2].Description = "North Avenue Store"; storeAddresses[2].StoreID = "6"; storeAddresses[2].Address = "1927 North Ave."; storeAddresses[2].City = "Chicago"; storeAddresses[2].State = "IL"; storeAddresses[2].ZIP = "60622"; recordSetResult = baServerHelper.CreateRecordSetByAddresses(storeAddresses, esriFolderType.esriFolderStoreLayers); // Create a table from the address record set tableData = new TableData(); tableData.RecordSet = recordSetResult.RecordSet; geocodeData = new GeocodeData(); geocodeData.Table = tableData; // ========= STEP 4: Geocode another record set with stores geocodeParameters = new CustomerStoreSetupByGeocodeTableParameters(); // Set specific analysis parameters geocodeParameters.GeocodeCustomers = false; geocodeParameters.GeocodeData = geocodeData; geocodeParameters.NameField = "NAME"; geocodeParameters.StoreIDField = "STORE_ID"; // Set other parameters imageOptions = null; outputOptions = new TaskOutputType[] { TaskOutputType.GetFeatureClass }; TaskResultOutput result = baServerHelper.CustomerStoreSetupByGeocodeTable(geocodeParameters, imageOptions, outputOptions, null); // Create a layer containing features to be added PointLayer sourceLayer = new PointLayer(); sourceLayer.RecordSet = result.RecordSet; // ========= STEP 5: Add features and test that features were added baServerHelper.AddFeatures(sourceLayer, outputLayer); result = baServerHelper.OpenFeatureLayer(outputLayer); bool featuresAdded = result.RecordSet.Records.Length == 6; |