Hi,
I have a question about FeatureSourceColumn and ColumnsValues of a feature on InMemoryFeatureLayer
When I create a Layer InMemoryFeatureLayer, I can define a featureSourceColumn as
Collection<FeatureSourceColumn> toto = new Collection<FeatureSourceColumn> ();
toto.Add(new FeatureSourceColumn(“CatalogueId”, “Int”, 30));
toto.Add(new FeatureSourceColumn(“AnalyseTerreId”, “Int”, 30));
toto.Add(new FeatureSourceColumn(“NumeroAnalyse”, “String”, 30));
toto.Add(new FeatureSourceColumn(“DateAnalyse”, “DateTime”, 10));
InMemoryFeatureLayer inMem = new InMemoryFeatureLayer(toto, fts);
So I define the type of the column as CatalogueId is a int , etc …
But if I add a feature on this layer, I want to add also the columnsValues (catalogueId ; AnalyseTerreId ; NumeroAnalyse ; DateAnalyse)…
So
Dictionary<string, string> dc = new Dictionary<string,string>();
dc.Add(“CatalogueId”,“564564”);
etc…
inMem.InternalFeatures.Add(new Feature(polygonShape,dc));
1) What is the goal to define the type of the variables in the featureSourceColumn because when we add a feature
the dictionary is string ?
2) I don’t understand the link between the FeatureSourceColummn and the columnsValues of a feature ?
Thanks a lot for your help.
Regards.
Steph.
FeatureSourceColumn and ColumnsValues : InMemoryFeatureLayer
Hi Steph,
ColumnsValues save data in feature, but data can only be saved as string, it’s in feature level.
The FeatureSourceColummn is in layer level, “Layer” ask user to register column value before use it. The FeatureSourceColummn contains “columnName”, “typeName” and “maxLength”.
ColumnName should be most important. Because if you don’t register the columnName, the layer will “drop” corresponding column value of feature in some functions itself.
The “typeName” and “maxLength” shows the property of target column, they won’t get strict validation, so whatever you set them won’t get exception in common scenario, but for some special layer for example ShapeFileFeatureLayer and MsSql2008FeatureLayer, you need set the correct type for data, orelse you will get some unexpected exceptions.
If I haven’t explained it clearly please let me know.
Regards,
Don
Hi Don,
Thanks for your help.
So FeatureSourceColumn is in the layer level and the columnValues is in feature layer.
I have few questions about one precise case :
I create the layer while specifying the FeatureSourceColumn but no feature initially.
In a second time, I want to add features in this layer that are currently in a c# class and with the corresponding data in the fetauresourceColumn.
Currently i do that :
foreach (Toto t in allTotos)
{
Dictionary dc = new Dictionary();
dc.Add("CatalogueId","564564");
etc…
inMem.InternalFeatures.Add(new Feature(polygonShape,dc));
}
I question the relevance of the statement featuresourceColumn upstream if I have to specify the columns in the featuresource dictionaryValues ?
And I tested if i can add a column in dictionaryvalue wich is not referenced in a FeatureSourceColumn and I had no error.
Thanks again for your help.
Regards.
Steph.
Hi Steph,
I guess this comes from the design of the FeatureSource. Actually, the InMemoryFeatureSource is just a short-cut to maintain the temporary features which are used in the memory, we consider it as a collection of features, just for users to operate them easily, so we didn’t do much validations for the FeatureSourceColumns registered at the very beginning and ones we added into the InternalFeatures as following. But if you call the “GetColumns”, it will just return the columns registered for the constructor. Sorry for the confusion, if it makes your application runs into error, please feel free to let me know, we can consider to do a check before adding and querying the features.
Thanks,
Johnny