Filtering Layers By Geometry
The layer definition for a vector layer can include a <Filter> element to select only certain features. The filter is a string that contains a valid FDO selection expression. See Selecting Using the API for a description of filters.
For example, assume the following:
- geomPoly is an MgPolygon representing the area of interest.
- geometry is the default geometry property for a feature class.
The following creates a filter to select only those features that intersect the polygon.
MgWktReaderWriter rw = new MgWktReaderWriter();
string wktGeom = rw.Write(geomPoly);
string filter = "geometry intersects GeomFromText(" +
wktGeom + ")" );
To modify the sample in Layer Definition to use the filter, set the <Filter> element as follows:
vectorLayerDef.Filter = filter;