ThinkGeo.com    |     Documentation    |     Premium Support

InMemoryFeatureLayer column values are all blank

Hi,


I have a PostgreSQL database, there are many tables to store the vehicle's point position,  one table for each vehicle. On the GUI, the user can choose the vehicle to view its points data, if the user selects more than one vehicle, I will retrieve them one by one. Once the data is retrieved using the PosgreSQLFeatureLayer, I select all the features from it and add the features to an InMemoryFeatureLayer.


The problem is, when I added the feature to the InmemoryFeatureLayer, I checked the column values are all right. But later when I select any features from the InMemoryFeatureLayer, the column values are all blank.


Where is wrong?


Any help is greatly appreciated!


Thanks


Rose


 



Rose,


I think the problem is you DID NOT add the correct columns for your InMemoryFeatureLayer.
 
Following is some codes how to create right InmemoryFeatureLayer for query:

ShapeFileFeatureLayer worldShapeLayer = new ShapeFileFeatureLayer(@"..\..\..\..\..\PostsData\Countries02.shp");
worldShapeLayer.Open();
Collection<Feature> allFeatures= worldShapeLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns);
Collection<FeatureSourceColumn> columns = worldShapeLayer.QueryTools.GetColumns();
worldShapeLayer.Close();
            

InMemoryFeatureLayer inmemoryFeatureLayer = new InMemoryFeatureLayer(columns,new Feature[]{});
foreach (Feature feature in allFeatures)
{
     inmemoryFeatureLayer.InternalFeatures.Add(feature);
}

Any more questions just let me know.


Thanks.
 
Yale

Yale:


Thanks for your response. I did add the correct columns for my InMemoryFeatureLayer.But when I query the features from the InMemoryFeatureLayer using following code, the column values are blank for the features in selectedFeatures, I want to add the selected features in a DataGridView.:


 



                Dim selectedFeatures As Collection(Of Feature)
                Dim inMemoryLyr As InMemoryFeatureLayer = DirectCast(Map1.FindFeatureLayer("PointsLayer"), InMemoryFeatureLayer)

                inMemoryLyr.Open()
                selectedFeatures = inMemoryLyr.QueryTools.GetFeaturesIntersecting(feature1, ReturningColumnsType.AllColumns)
                inMemoryLyr.Close()


Rose,


This work fine in my test sample, see my attached sample. Only difference with your requirements is that the features added to the InmemoryFeatureLayer is from the shape file instead of the database as you said.
 
Let me know if any more questions have.
 
Thanks.
 
Yale

978-Post_6061_Sample.zip (11.1 KB)

Yale:


The sample code works for me too.


I don't why the columnValues for the selectedFeatures from the InMemoryFeatureLayer  using the QueryTool are all zero, I checked the InternalFeatures of the InMemoryFeatureLayer before I use the QueryTool, I could see the column values are not blank..


Thanks


 


Rose



Rose, 
  
 Great news! Thanks for letting me know this! 
  
 Let me know if any more questions. 
  
 Thanks. 
  
 Yale