Accessing attributes/fields from shapefile .dbf

Nov 21, 2010 at 9:10 PM

Hi, I've tried searching but can't find any references to this exactly.

I have a centerline shapefile that includes roads, highways, rivers, bicycle paths, etc. I would like to filter out everything but motor vehicle roads. This information is in a variable called FCODE, which is a field of each line in the shapefile. Is it possible to do this in SharpMap? Thanks

Alexander

Coordinator
Nov 22, 2010 at 7:13 AM

Hello asfarley,

it is possible to do that, you have to define a FilterMethod that is being called during ExecuteFeatureQuery calls

Here is a sample:

public static bool FCodeFilter(SharpMap.Data.FeatureDataRow row)
{
    if(row["FCODE"] == <someValue>)
        return true;
    return false;
}

All you have to do now is to assign this function to the ShapeFile providers FilterDelegate property.

Hth FObermaier