Hi,
I was trying to add a feature source column using the AddColumn method, but it always throws an exception. The code I used is below - just wondering what the difference is between the two methods.
Thanks,
Steve
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
{
map1.MapUnit = GeographyUnit.Meter;
var l = new InMemoryFeatureLayer();
l.FeatureSource.Open();
l.FeatureSource.AddColumn(new FeatureSourceColumn("col1")); // this fails
l.FeatureSource.GetColumns().Add(new FeatureSourceColumn("COL2"));// this works
Debug.Assert(1 == l.FeatureSource.GetColumns().Count());
l.FeatureSource.Close();
var l2 = new InMemoryMarkerOverlay();
l2.FeatureSource.Open();
l2.FeatureSource.AddColumn(new FeatureSourceColumn("col1"));// this fails
l2.FeatureSource.GetColumns().Add(new FeatureSourceColumn("COL2")); // this works
Debug.Assert(1 == l2.FeatureSource.GetColumns().Count());
l2.FeatureSource.Close();
}
What is FeatureSource.AddColumn for?
Hi Steve,
The FeatureSource.AddColumn method is an new API in Map Suite 7.0 and it should works with the “CanModifyColumnStructure” property together. Currently, only a few layers can support this feature, like ShapeFileFeatureLayer,FileGeodatabaseLayer. The other layers like here InMemoryFeatureLayer and InMemoryMarkerOverlay are not fit for the API’s purpose.
So, before using this API, we need to check if the CanModifyColumnStructure property.
Thanks,
Johnny
Hi Johhny,
Thanks for that. Can I make a suggestion for the exception message - to prevent confusion for future users, if something like AddColumn() is not supported, then maybe add a message to your exception with something like “This method is not supported for this layer. Please check the ‘CanModifyColumnStructure’ property.”
Cheers,
Steve
Hi Steve,
I guess you are right, I will discuss with our develop team to give a more clear exception message.
Thanks for the suggestion.
Best regards,
Johnny