ThinkGeo.com    |     Documentation    |     Premium Support

How to query InMemoryFeatureLayer ,i losed feature.ColumnValues

Hello,



I need query InMemoryFeatureLayer,my code:

// this.FeaturesLayer is a InMemoryFeatureLayer , it is point layer and some point show in the osm map;  

// wpfMap1.MapUnit = GeographyUnit.Meter; map is online  osm map;

//It will realize map click point in the map,get the points’s features (may be get some points,because if points in the new EllipseShape(point, 80, 80));

//add one point in the InMemoryFeatureLayer function code(this.FeaturesLayer have some points):

                    feature = CreateFeaturePoint(x, y);
                    feature.ColumnValues[attributeId] = id.ToString();
                    feature.ColumnValues[attributeLabel] = label;
                    feature.ColumnValues[attributeType] = type;
                    feature.ColumnValues[attributeStatus] = status;
    

                    this.FeaturesLayer.InternalFeatures.Add(feature);
//some information add in the   feature.ColumnValues ; 

//However,I using  the following code.I can succeed to get the features, but evey feature’s  feature.ColumnValues is losed  in the features;

//only get the point’s coordinates. 
//the point is map click get the point.

IEnumerable<Feature> features=

this.FeaturesLayer.QueryTools.GetFeaturesWithin(new EllipseShape(point, 80, 80), ReturningColumnsType.AllColumns);


IEnumerator enumerator = features.GetEnumerator();



            while (enumerator.MoveNext())
            {
                Feature feature= enumerator.Current as Feature;

     //i need Dictionary<string, string>,like feature.ColumnValues
               // string id = feature.ColumnValues[attributeId]   // it’s not find attributeId;
            }


Finally,how to query the InMemoryFeatureLayer, use this.FeaturesLayer.QueryTools? Can I query the this.FeaturesLayer.InternalFeatures?

If it can query ,and how to query this.FeaturesLayer.InternalFeatures?

Hi Burning,



The codes look fine but what I guess the issue is happened you are missing to add dbf columns into InMemoryFeatureLayer when creating the instance. Some codes like:


Collection<FeatureSourceColumn> columns = new Collection<FeatureSourceColumn>();
            columns.Add(new FeatureSourceColumn("attributeId"));
            columns.Add(new FeatureSourceColumn("attributeLabel"));
            //…
            InMemoryFeatureLayer laye = new InMemoryFeatureLayer(columns, new Collection<BaseShape>());

Please try it and let us know if your issues solved.

Thanks,

Troy