Quantcast
Channel: DotSpatial
Viewing all articles
Browse latest Browse all 3973

New Post: Function like "Definition Query" for layer

$
0
0
Still not sure what you mean by work with. Are you referring to what the user would see on the screen (i.e. some features would not be visible) or do you want your internal code to just have a subset of all features?

In any case, here is how you can select features based on a query and then make them not visible:
            ParentLayer.Selection.Clear();
            //Select desired features
            ParentLayer.SelectByAttribute(YOUR QUERY);

            //Make every feature invisible
            foreach (IFeature f in ParentLayer.DataSet.Features)
            {ParentLayer.SetVisible(f, false);}

            //Make the selected Features visible again
            foreach (IFeature f in ParentLayer.Selection.ToFeatureList())
            {ParentLayer.SetVisible(f, true);}
            ParentLayer.Selection.Clear();
In your code you can then check if a feature is visible by using the GetVisible method or you can just use SelectByAttribute and Selection.ToFeatureSet() to make a new featureset.

Viewing all articles
Browse latest Browse all 3973

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>