ThinkGeo.com    |     Documentation    |     Premium Support

How to get table name from MultipleFeatureSource?

I want to get table name from MultipleFeatureSource.


 


my solution :


1. add MSSQL2008Featuresource(tablename : school,hospital,minimart )  to MultipleFeatureSource.  


2. I use buffer for get feature. (I use MultipleFeatureSource.SpatialQuery )


3.I save feature to  Collection<feature>.</feature>


4. I can get all attributes and column name of features but I can't get table name. I try to find it but not found.


 How I know a feature is in what table?


Help me please.


Thank you.



 Sumeth, 


             
You can get the table name by customizing the SpatialQueryCore method in MultipleFeatureSource. Here is the code: 
 

public class MyMultipleFeatureSource : MultipleFeatureSource
    {
        protected override Collection<Feature> SpatialQueryCore(BaseShape targetShape, QueryType queryType, IEnumerable<string> returningColumnNames)
        {
            Collection<Feature> returnFeatures = new Collection<Feature>();
            foreach (FeatureSource featureSource in FeatureSources)
            {
                Collection<Feature> features = featureSource.SpatialQuery(targetShape, queryType, returningColumnNames);
                string tableName = ((MsSql2008FeatureSource)featureSource).TableName;
                foreach (Feature feature in features)
                {
                    Feature newFeature = feature;
                    newFeature.Tag = tableName;
                    returnFeatures.Add(newFeature);
                }
            }
            return returnFeatures;
        }
}

 
The features returning from the SpatialQuery Method all have the Table Name stored in the Tag property. 
 

Collection<Feature> features = myMultipleFeatureSource.SpatialQuery(myMultipleFeatureSource.GetBoundingBox(), QueryType.Intersects, ReturningColumnsType.AllColumns);
 
Of course you can save the table name in other ways such as creating a new Feature column if you would like to.
 
Thanks,
 
Ben

thanks you very much. :)

Ben, thank you so much for helping on that one.